From: Roland G. <RGi...@cp...> - 2006-08-16 09:58:09
|
how about doing a $exp->send("version\r"); ?? PS: BTW, what is Nabble.com?! On 8/15/06, fastaero <raj...@gm...> wrote: > > my $exp = Expect->spawn("telnet 1.2.3.4"); > > my $timeout = 10; > my $username = 'lab'; > my $password = 'test1'; > > my $spawn_ok; > $exp->expect($timeout, > [ > qr'login:', > sub { > $spawn_ok = 1; > my $fh = shift; > $fh->send("$username\n"); > exp_continue; > } > ], > [ > qr'Password:', > sub { > my $fh = shift; > $fh->send("$password\n"); > exp_continue; > } > ], > eof => > sub { > if ($spawn_ok) { > die "ERROR: premature EOF in login.\n"; > } else { > die "ERROR: could not spawn telnet.\n"; > } > } > ], > [ > timeout => > sub { > die "No login.\n"; > } > ], > '-re',qr'>', #' wait for shell prompt, then exit expect > > ); > > my $exp1 = Expect->spawn("load"); > print "$exp1\n"; > > > how do I execute commands on the telneted machine using the above scripts? > login and password works fine, I want to execute "version" and get the > version number of the machine. How can I do that with using about sub? > > > my $telnet = new Net::Telnet ("1.2.3.4") > or die "Cannot telnet to remotehost: $!\n"; > #my $exp = Expect->exp_init($telnet); > > This is not working for some reason? Any ideas on why? > > Thanks > -- > View this message in context: http://www.nabble.com/need-help-with-expect%28%29-tf2107189.html#a5808510 > Sent from the Perl - Expectperl-Discuss forum at Nabble.com. > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > -- RGi...@cp... |