Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help needed with Net::Telnet

Reply
Thread Tools

Help needed with Net::Telnet

 
 
Shotoku Taishi
Guest
Posts: n/a
 
      06-24-2003
Hi

I would like to run commands remotely using net::telnet from CPAN.

I am trying to run the following:

#!/usr/bin/perl -w
use strict;
use Net::Telnet;

my $host= "Andromeda";
my $username = "Andro";
my $passwd = "stars";


$t = new Net::Telnet (Timeout => 10,
Prompt => '/c:\\\\users\\\\andro>$/i');
$t->open("$host");
$t->login($username, $passwd);
@lines = $t->cmd("ls");
print @lines;

I get the following error message:

Global symbol "$t" requires explicit package name

Thanks

Mike





 
Reply With Quote
 
 
 
 
Michael Budash
Guest
Posts: n/a
 
      06-24-2003
In article <bd9ngn$t4g$(E-Mail Removed)>,
"Shotoku Taishi" <(E-Mail Removed)> wrote:

> Hi
>
> I would like to run commands remotely using net::telnet from CPAN.
>
> I am trying to run the following:
>
> #!/usr/bin/perl -w
> use strict;
> use Net::Telnet;
>
> my $host= "Andromeda";
> my $username = "Andro";
> my $passwd = "stars";


above it look sllike you understand about 'use strict;', but below it
appears you do not...

> $t = new Net::Telnet (Timeout => 10,
> Prompt => '/c:\\\\users\\\\andro>$/i');


s/b:

my $t = new Net::Telnet (Timeout => 10,
Prompt => '/c:\\\\users\\\\andro>$/i');

> $t->open("$host");
> $t->login($username, $passwd);
> @lines = $t->cmd("ls");


s/b:

my @lines = $t->cmd("ls");

> print @lines;
>
> I get the following error message:
>
> Global symbol "$t" requires explicit package name


i'm quite sure you're seeing more than just one such error... but make
the changes and your script should at least compile...

hth-

--
Michael Budash
 
Reply With Quote
 
 
 
 
Shotoku Taishi
Guest
Posts: n/a
 
      06-24-2003
Thank you. At least I got it to compile now. I did not know use strict; was
that strict.

Now I get the following error:

timed-out waiting for login prompt at C:\test\mike.pl line 13

Thank you for your help so far.

Mike

"Michael Budash" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <bd9ngn$t4g$(E-Mail Removed)>,
> "Shotoku Taishi" <(E-Mail Removed)> wrote:
>
> > Hi
> >
> > I would like to run commands remotely using net::telnet from CPAN.
> >
> > I am trying to run the following:
> >
> > #!/usr/bin/perl -w
> > use strict;
> > use Net::Telnet;
> >
> > my $host= "Andromeda";
> > my $username = "Andro";
> > my $passwd = "stars";

>
> above it look sllike you understand about 'use strict;', but below it
> appears you do not...
>
> > $t = new Net::Telnet (Timeout => 10,
> > Prompt => '/c:\\\\users\\\\andro>$/i');

>
> s/b:
>
> my $t = new Net::Telnet (Timeout => 10,
> Prompt => '/c:\\\\users\\\\andro>$/i');
>
> > $t->open("$host");
> > $t->login($username, $passwd);
> > @lines = $t->cmd("ls");

>
> s/b:
>
> my @lines = $t->cmd("ls");
>
> > print @lines;
> >
> > I get the following error message:
> >
> > Global symbol "$t" requires explicit package name

>
> i'm quite sure you're seeing more than just one such error... but make
> the changes and your script should at least compile...
>
> hth-
>
> --
> Michael Budash



 
Reply With Quote
 
Shotoku Taishi
Guest
Posts: n/a
 
      06-24-2003
Hi

If I telnet a Unix box and if I use:

Prompt => '/%/');

I do manage to run the "ls" command on the remote host.

I am having real problems with the Windows prompt.though

"Shotoku Taishi" <(E-Mail Removed)> wrote in message
news:bda8ai$2rl$(E-Mail Removed)...
> Thank you. At least I got it to compile now. I did not know use strict;

was
> that strict.
>
> Now I get the following error:
>
> timed-out waiting for login prompt at C:\test\mike.pl line 13
>
> Thank you for your help so far.
>
> Mike
>
> "Michael Budash" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > In article <bd9ngn$t4g$(E-Mail Removed)>,
> > "Shotoku Taishi" <(E-Mail Removed)> wrote:
> >
> > > Hi
> > >
> > > I would like to run commands remotely using net::telnet from CPAN.
> > >
> > > I am trying to run the following:
> > >
> > > #!/usr/bin/perl -w
> > > use strict;
> > > use Net::Telnet;
> > >
> > > my $host= "Andromeda";
> > > my $username = "Andro";
> > > my $passwd = "stars";

> >
> > above it look sllike you understand about 'use strict;', but below it
> > appears you do not...
> >
> > > $t = new Net::Telnet (Timeout => 10,
> > > Prompt => '/c:\\\\users\\\\andro>$/i');

> >
> > s/b:
> >
> > my $t = new Net::Telnet (Timeout => 10,
> > Prompt => '/c:\\\\users\\\\andro>$/i');
> >
> > > $t->open("$host");
> > > $t->login($username, $passwd);
> > > @lines = $t->cmd("ls");

> >
> > s/b:
> >
> > my @lines = $t->cmd("ls");
> >
> > > print @lines;
> > >
> > > I get the following error message:
> > >
> > > Global symbol "$t" requires explicit package name

> >
> > i'm quite sure you're seeing more than just one such error... but make
> > the changes and your script should at least compile...
> >
> > hth-
> >
> > --
> > Michael Budash

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
Help Help Help Please Pentax S5i info needed The Martian Digital Photography 2 05-20-2008 07:00 AM
Help needed on this 857W config. Repost to be clearer what the problemsare and the help needed sparticle Cisco 3 08-30-2007 07:47 PM
Ideas needed & help needed! Ryan Macy Ruby 2 07-19-2006 08:04 PM
Microsoft small business server 2003 - help needed to understand what is needed to use it Dima Computer Support 5 10-20-2004 08:27 PM



Advertisments