djkumar72 has asked for the wisdom of the Perl Monks concerning the following question:

I could not connect to a Unix mwchine using Telnet package. I am getting error message "eof read waiting for login prompt: at testperl.txt line 11". This is the simple script i am using.
#!/usr/bin/perl use strict; use Net::Telnet (); my $telnet; my $output; $telnet = new Net::Telnet->new( Timeout=>20,Prompt => '/[\$%#>] $/'); die &Log_Message("Can't open telnet session to the remote host") unles +s $telnet; $output = $telnet->open("hppi003"); print $output; $output = $telnet->login("astwrk2","unix11"); print $output; print "Logged into the system \n"; print "End";

Replies are listed 'Best First'.
Re: using Telnet
by blazar (Canon) on Jul 04, 2005 at 09:46 UTC
    $telnet = new Net::Telnet->new( Timeout=>20,Prompt => '/[\$%#>] $/');
    I think there's something "new" that shouldn't be there...

    Incidentally,

    1. maybe you knew, maybe you didn't: the &-form of sub call shouldn't be used in most cases, nowadays;
    2. I don't know Net::Telnet, but I guess $telnet->open() returns a FH, doesn't it? Then maybe you really want to
      print $output $something;