Michael Butler/CanEast/IBM wrote:

> Hi Brett,
> Thanks for the help. At least I know the code works. I can't connect to a
> RedHat 6.2 box or any one of 10 AIX boxes. Interesting that it would work
> for you. I'll try by ip address although I know that I can connect by name
> its just that I get the response that it is waiting for a command prompt.
>
> Thanks again
> Mike
>
> Bret Hughes <[EMAIL PROTECTED]> on 09/12/2000 08:18:02 PM
>
> Please respond to [EMAIL PROTECTED]
>
> To:   [EMAIL PROTECTED]
> cc:
> Subject:  Re: [OT] Perl Telnet script
>
> Michael Butler/CanEast/IBM wrote:
>
> > Sorry for the off topic question but I'm scratching my head here. I've
> > written a perl script to do a telnet to a server and run an arbitrary
> > command. Doing a "who" on the server indicates that I do indeed get
> > connected. However, after the specified timeout I get "connection timed
> out
> > waiting for a command prompt". Here's my code:
> >
> > #!/usr/bin/perl
> > use Net::Telnet;
> > $telnet = Net::Telnet->new
> > (
> >  Timeout=>10, Prompt=>'/[\$%#>] $/', Host=>'berkeley'
> >  );
> > $telnet->login('mbutler', 'xxxxx');
> > @listing = $telnet->cmd("ls");
> > print @listing;
> > $telnet->close;
> >
> > Anyone got any ideas?
>
> Another data point:
>
> Worked for me connecting to a pinstripe box.  The only one I have running
> telnet.  I just changed the host, username and password in your script
> and...
> bingo a listing of the home dir.
>
> BTW I used the ipaddress since the test box IP is not resolved via my
> internal
> DNS.  I don't know what your setup is but that might be worth a try.  Have
> you
> tried increasing the timeout?
>
> Hope this helps,
>
> Bret

That is interesting.  I have no idea how fast the versions change in the perl
mods but here is what I have in the way perl stuff on my 6.2 machine

[bhughes@bretdell_linux bhughes]$ rpm -qa|grep perl
perl-HTML-Parser-3.05-6
groff-perl-1.15-8
perl-Text-CSV-0.01-6
perl-libwww-perl-5.47-6
perl-libnet-1.0605-2
perl-URI-1.05-6
perl-Text-CSV_XS-0.20-6
perl-5.00503-12
perl-Net-Telnet-3.01-6

Here is the script I ran.

#!/usr/bin/perl
use Net::Telnet;
$telnet = Net::Telnet->new
(
 Timeout=>10, Prompt=>'/[\$%#>] $/', Host=>'192.168.0.148'
 );
$telnet->login('bhughes', 'xxxxxxxx');
@listing = $telnet->cmd("ls");
print @listing;
$telnet->close;


hth
Bret




_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to