From: Juan P. F. G. <jfe...@gm...> - 2007-12-14 00:59:46
|
> > configurationFile =3D=3D> PerlScript <=3D=3D> InstallerProgram > > Script: [Name: telnet.pl] > --------------------------- > #!/usr/local/bin/perl > > use Expect; > use Net::Telnet; > > $prompt =3D '/[\]%>#\$]\s$/i'; > > $telnetObj =3D new Net::Telnet ( Timeout =3D> 20, Prompt =3D> $prompt); > $telnetObj->open ('host1'); > > $telnet =3D Expect->exp_init ($telnetObj); > $telnet->log_stdout (1); > > $telnet->expect (20, 'login: '); > $telnet->send ("user\r"); > $telnet->expect (20, 'Password: '); > $telnet->send ("password\r"); > > $telnet->expect (20, -re, $prompt); > $telnet->send ("id\r"); > $telnet->expect (20, -re, $prompt); > $telnet->send ("ls -ltr\r"); > > $telnet->hard_close(); > > ## END OF SCRIPT ## > > > Output: > --------------------------- > # ./telnet.pl > =FF=FD% > # > --------------------------- try using a 'spawn' to lunch the connection... my $command=3D"telnet x.x.x.x"; # or pass the host at @params array $rootexpect=3DExpect->spawn($command, @params) or die "$command: $! FALLO\n= "; Then add some debug with expect internal to get an idea where the script is stuck.. $rootexpect->exp_internal('1'); Hope it helps Good luck |