Help needed with Net::Telnet

Discussion in 'Perl Misc' started by Shotoku Taishi, Jun 24, 2003.

  1. 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
    Shotoku Taishi, Jun 24, 2003
    #1
    1. Advertising

  2. In article <bd9ngn$t4g$>,
    "Shotoku Taishi" <> 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
    Michael Budash, Jun 24, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    > In article <bd9ngn$t4g$>,
    > "Shotoku Taishi" <> 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
    Shotoku Taishi, Jun 24, 2003
    #3
  4. 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" <> wrote in message
    news:bda8ai$2rl$...
    > 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" <> wrote in message
    > news:...
    > > In article <bd9ngn$t4g$>,
    > > "Shotoku Taishi" <> 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

    >
    >
    Shotoku Taishi, Jun 24, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Isaacson
    Replies:
    5
    Views:
    593
    Default User
    Nov 5, 2004
  2. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
  3. Robert
    Replies:
    0
    Views:
    106
    Robert
    Sep 11, 2003
  4. Replies:
    0
    Views:
    75
  5. Replies:
    4
    Views:
    222
Loading...

Share This Page