On Friday, May 24, 2002, at 08:12 , Naser Ali wrote:

> Hello everyone,
>
> I have gotten this program from the Net::Telnet readme file, but it does 
> not
> work. When I run it it output a message which I don't understand. How can 
> I
> give it userid and passwd for the telnet session..?
>
> ===============Program segment=================
> #!/usr/bin/perl
>
> use Net::Telnet ();
> $t = new Net::Telnet (Timeout => 10,
>                       Prompt => '/ksh\$ $/');
> $t->open("coyote");
> $t->login($username, $passwd);
> @lines = $t->cmd("/usr/bin/who");
> print @lines;
> ===============================================

two things really

        a) try that with the -w and use strict

        b) you should use a username and passwd
                traditionally when you want to sent that code
                you should have it as

                my ($username, $passwd) = ('XXXXXX','YYYYYY');

At which point, go back and check your 'prompt' token,
since on Jeeves I would set it for:

        'drieux%'

since it normally looks like

        [jeeves:~] drieux%

whereas on vladimir/xanana/etc I get

        vladimir: 52:]
        xanana: 52:]

so what you find me doing is stuff like

sed 's/^/### /' NetSilly.pl
### #!/usr/bin/perl -w
###
### my ($farhost, $username, $passwd) = qw/xanana XXXX YYYYY/;
###
### my $prompt = '/' . $farhost . ':\s*\d+:]\s*/' ;
###
### use Net::Telnet ();
### my $t = new Net::Telnet (Timeout => 10,
###                       Prompt => $prompt );
### $t->open($farhost);
### $t->login($username, $passwd);
### my @lines = $t->cmd("hostname; echo 'we are Here'");
### print @lines;
###

since if I used the 'stock' prompt from the perlDoc it
will not match my personal one....

and yea - do NOT do that as
        /^.....$/

since you really do not want to pass a FULL UGLY Regular
Expression as a prompt match - be liberal, be open...


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to