From: Frank S. <fr...@sc...> - 2008-01-28 11:45:44
|
hi, i tried a little script, which works well on Cisco Routers ####################################################################### my $telnet =3D3D Net::Telnet->new(Host=3D3D>${routername}); my ${ExpectObject}=3D3DExpect->exp_init($telnet); ${ExpectObject}->debug(1); ${ExpectObject}->log_file("/tmp/test.log"); ${ExpectObject}->expect( ${timeout}, [qr/(username|login): /i, sub { my $exp=3D3Dshift; $exp->send("${username}\n"); exp_continue; } ], [qr/password: /i, sub { my $exp=3D3Dshift; $exp->send("${password}\n"); exp_continue; } ], '-re',qr/[^\n]*(>|#)[\ \t]*/ ); ${ExpectObject}->send("exit"); ######################################################################## but if i try it on a juniper router, the only output i get in /tmp/test.log looks like that: =FF=FD^X=FF=FD =FF=FD#=FF=FD'=FF=FD$ in hex: root@nvm1:/tmp# od -x /tmp/test.log 0000000 fdff ff18 20fd fdff ff23 27fd fdff 0024 0000017 root@nvm1:/tmp# NB: I would like to use net::telnet, because (IMHO) the error handling with spawn(telnet) is awful. The combination expect->spawn->telnet works well except error handling and net::telnet ("standalone") also works well, but i have already a bunch of modules based on Expect.pm which i don`t want to rewrite. This is why i would prefer the combination of Expect and Net::Telnet. Any thoughts? greets M0ses |