in reply to Net::Telnet timed out when logging in

hi guys, alright i've managed to use glide's code to work apparently when i use login(), i can't can't to let it work 'cos of i need a prompt which i dunno what it is for windows XP below is my latest code:
#!/perl/bin/perl use strict; use Net::Telnet(); my $telnet; $telnet = new Net::Telnet ( Timeout=>10, Errmode=> 'return'); $telnet->open('ip_address')or die "failed to connect:$!"; $telnet->waitfor( -match => qr{ogin} ); $telnet->print("username"); $telnet->waitfor( -match => qr{assword} ); $telnet->print("password"); $telnet->input_log("C:\\log.txt"); $telnet->dump_log("c:\\dump.txt"); print("login successful");
apparantly no errors is out and it prints login successful.
but the dump_log and input_log doesn't seem to contain any information so i'm not too sure if connection to telnet is made yet.
about what i'm doing i need to connect to SQL database with another proprietary database.
and this proprietary database is in a switch which i need to telnet into.
it's all sorta like a automation thing that i need to help my colleges do for easy documentation.
so now i need to try the first step and that's to establish a connection with telnet..
so how do i know if it's working? hope my code is correct..pls help? thanks

Replies are listed 'Best First'.
Re^2: Net::Telnet timed out when logging in
by regexes (Hermit) on Apr 18, 2008 at 06:36 UTC
    Hmmm... what prompt do you receive when you log in using a telnet client from the command line, i.e. without using perl?

    regexes
      alright the prompt i get is as such below
      Trying 010200016058....Open ENTER USERNAME <
      after i type in my username
      i get
      ENTER PASSWORD <
      i'm telneting into a proprietary swtich which makes things really difficult
        Try something like this below. Since you know what the prompt is when logging in manually, use it during creation of the object.
        use Net::Telnet; my $telnet3; $telnet3 = new Net::Telnet(timeout => 10, Errmode => 'die' Prompt => '/ENTER USERNAME </'); $telnet3->open('10.200.16.58'); $telnet3->login('IATEST', 'TESTBED'); @lines = $telnet3->cmd("who"); open(FILE, ">file.txt"); print FILE ("@lines\n"); print("logged in to the device.\n");
        Maybe that helps?

        regexes
Re^2: Net::Telnet timed out when logging in
by poolboi (Acolyte) on Apr 18, 2008 at 03:26 UTC
    hi guys, alright i've managed to use glide's code to work apparently when i use login(), i can't can't to let it work 'cos of i need a prompt which i dunno what it is for windows XP below is my latest code:
    #!/perl/bin/perl use strict; use Net::Telnet(); my $telnet; $telnet = new Net::Telnet ( Timeout=>10, Errmode=> 'return'); $telnet->open('ip_address')or die "failed to connect:$!"; $telnet->waitfor( -match => qr{ogin} ); $telnet->print("username"); $telnet->waitfor( -match => qr{assword} ); $telnet->print("password"); $telnet->input_log("C:\\log.txt"); $telnet->dump_log("c:\\dump.txt"); print("login successful");
    apparantly no errors is out and it prints login successful.
    but the dump_log and input_log doesn't seem to contain any information so i'm not too sure if connection to telnet is made yet.
    about what i'm doing i need to connect to SQL database with another proprietary database.
    and this proprietary database is in a switch which i need to telnet into.
    it's all sorta like a automation thing that i need to help my colleges do for easy documentation.
    so now i need to try the first step and that's to establish a connection with telnet..
    so how do i know if it's working? hope my code is correct..pls help? thanks