From: Brandon C. <bra...@me...> - 2008-12-11 05:01:49
|
I have an expect script as follows: spawn telnet X.X.X.X $podport set timeout 15 sleep 2 send $controlZ send "\r" expect { "no]:" exit ")#" exit "#" {send "\r"} ">" {send "enable\r"} } expect { "Password:" {send "sanfran\r"} "#" {send "\r"} } expect { "Password:" {send "cisco\r"} "#" {send "\r"} } expect { "Password" {send "sanjose\r"} "#" {send "\r"} } expect { "% Bad passwords" exit "#" {send "wr\r"} } expect { "#" {send "write erase\r"} } expect "confirm" send "\r" expect "#" send "reload \r" expect "Proceed with reload?" send "\r" puts "reset of $podport complete\n\n" exit The expect script does exactly what I want it to do, however I cant seem to figure out how to call it from a perl script. So I think I may need to re-write it in Expect.pl and if thats the case how do I express the section: expect { "no]:" exit ")#" exit "#" {send "\r"} ">" {send "enable\r"} } in the Expect.pl? Or, is there an easy way to just tell perl to run the script? Thanks for any help anyone can offer! Brandon Carroll bra...@ma... http://www.brandonjcarroll.com http://www.globalconfig.net |
From: Ken I. <fn...@ua...> - 2008-12-11 05:29:43
|
On Wed, Dec 10, 2008 at 09:01:43PM -0800, Brandon Carroll wrote: > I have an expect script as follows: > > spawn telnet X.X.X.X $podport > set timeout 15 > sleep 2 > send $controlZ > send "\r" > > > expect { > "no]:" exit ... > puts "reset of $podport complete\n\n" > exit > > The expect script does exactly what I want it to do, however I cant > seem to figure out how to call it from a perl script. So I think I > may need to re-write it in Expect.pl and if thats the case how do I > express the section: > expect { > "no]:" exit > > ")#" exit > > "#" {send "\r"} > ">" {send "enable\r"} > } > in the Expect.pl? Or, is there an easy way to just tell perl to run > the script? The system function ought to be able to do that, it just executes a shell command, and I think returns exit status. Or use backticks if you want to grab output from the process. You may need to specify the path to your executable expect script or to expect itself. If you have a full perl distribution help/man pages should be available, e.g., perldoc -f system Ken > > Thanks for any help anyone can offer! > Brandon Carroll > bra...@ma... > http://www.brandonjcarroll.com > http://www.globalconfig.net -- Ken Irving, fn...@ua..., 907-474-6152 Water and Environmental Research Center Institute of Northern Engineering University of Alaska, Fairbanks |
From: Bradford R. <bri...@po...> - 2008-12-11 12:18:11
|
What happens when you try $status = system("/my/path/expect_script x.x.x.x"); or @output = `/mypath/expect_script x.x.x.x`; On Thu, Dec 11, 2008 at 12:01 AM, Brandon Carroll <bra...@me...>wrote: > I have an expect script as follows: > > spawn telnet X.X.X.X $podport > set timeout 15 > sleep 2 > send $controlZ > send "\r" > > > expect { > "no]:" exit > > ")#" exit > > "#" {send "\r"} > ">" {send "enable\r"} > } > expect { > "Password:" {send "sanfran\r"} > "#" {send "\r"} > } > expect { > "Password:" {send "cisco\r"} > "#" {send "\r"} > } > expect { > "Password" {send "sanjose\r"} > "#" {send "\r"} > } > expect { > "% Bad passwords" exit > "#" {send "wr\r"} > } > expect { > "#" {send "write erase\r"} > } > expect "confirm" > send "\r" > expect "#" > send "reload \r" > expect "Proceed with reload?" > send "\r" > puts "reset of $podport complete\n\n" > exit > > The expect script does exactly what I want it to do, however I cant > seem to figure out how to call it from a perl script. So I think I > may need to re-write it in Expect.pl and if thats the case how do I > express the section: > expect { > "no]:" exit > > ")#" exit > > "#" {send "\r"} > ">" {send "enable\r"} > } > in the Expect.pl? Or, is there an easy way to just tell perl to run > the script? > > Thanks for any help anyone can offer! > Brandon Carroll > bra...@ma... > http://www.brandonjcarroll.com > http://www.globalconfig.net > > > > > > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada. > The future of the web can't happen without you. Join us at MIX09 to help > pave the way to the Next Web now. Learn more and register at > > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |
From: Brandon C. <bra...@me...> - 2008-12-11 16:05:48
|
You just made my day! @output = `/mypath/expect_script x.x.x.x`; worked like a champ! Thanks so much! Brandon Carroll bra...@ma... http://www.brandonjcarroll.com http://www.globalconfig.net On Dec 11, 2008, at 3:49 AM, Bradford Ritchie wrote: > What happens when you try > $status = system("/my/path/expect_script x.x.x.x"); > or > @output = `/mypath/expect_script x.x.x.x`; > > > > On Thu, Dec 11, 2008 at 12:01 AM, Brandon Carroll <bra...@me... > > wrote: > I have an expect script as follows: > > spawn telnet X.X.X.X $podport > set timeout 15 > sleep 2 > send $controlZ > send "\r" > > > expect { > "no]:" exit > > ")#" exit > > "#" {send "\r"} > ">" {send "enable\r"} > } > expect { > "Password:" {send "sanfran\r"} > "#" {send "\r"} > } > expect { > "Password:" {send "cisco\r"} > "#" {send "\r"} > } > expect { > "Password" {send "sanjose\r"} > "#" {send "\r"} > } > expect { > "% Bad passwords" exit > "#" {send "wr\r"} > } > expect { > "#" {send "write erase\r"} > } > expect "confirm" > send "\r" > expect "#" > send "reload \r" > expect "Proceed with reload?" > send "\r" > puts "reset of $podport complete\n\n" > exit > > The expect script does exactly what I want it to do, however I cant > seem to figure out how to call it from a perl script. So I think I > may need to re-write it in Expect.pl and if thats the case how do I > express the section: > expect { > "no]:" exit > > ")#" exit > > "#" {send "\r"} > ">" {send "enable\r"} > } > in the Expect.pl? Or, is there an easy way to just tell perl to run > the script? > > Thanks for any help anyone can offer! > Brandon Carroll > bra...@ma... > http://www.brandonjcarroll.com > http://www.globalconfig.net > > > > > > > ------------------------------------------------------------------------------ > SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, > Nevada. > The future of the web can't happen without you. Join us at MIX09 to > help > pave the way to the Next Web now. Learn more and register at > http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/ > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > |