Perl et Telnet

Discussion in 'Perl Misc' started by ThERiZla, Dec 1, 2003.

  1. ThERiZla

    ThERiZla Guest

    Hi,

    I do a connection on the server witn Telnet.
    My problem is when I execute a command on command prompt.
    This is my command : my @outputcreateUser = $telnet->cmd($createUser);
    I want obtain the result of the command but when I print the array
    @outputCreateUser there is nothing in the array.

    This is my code to connect to the server:
    ## Create a Net::Telnet object
    use Net::Telnet ();
    $telnet = new Net::Telnet (Timeout => 20,
    Input_log => $fileInput,
    Output_log => $fileOutput,
    Errmode => 'return',
    Prompt => $prompt);
    if (! defined $telnet) {
    die "Unable to create telnet object for $host";
    }

    $telnet->open($host);
    if ($msg = $telnet->errmsg) {
    die "Unable to open telnet to $host $msg";
    }

    $telnet->login($username, $password);
    if ($msg = $telnet->errmsg) {
    die "Unable to login to $host $msg PWD: $password";
    }
    return $telnet;


    I like know if I do something wrong.
    An explication and an example will be appreciate.
    Thanks
    ThERiZla, Dec 1, 2003
    #1
    1. Advertising

  2. ThERiZla

    J. Gleixner Guest

    ThERiZla wrote:
    > Hi,
    >
    > I do a connection on the server witn Telnet.
    > My problem is when I execute a command on command prompt.
    > This is my command : my @outputcreateUser = $telnet->cmd($createUser);
    > I want obtain the result of the command but when I print the array
    > @outputCreateUser there is nothing in the array.


    ahhh... so your code looks exactly like:

    my @outputcreateUser = $telnet->cmd($createUser);
    print @outputCreateUser;

    Case is important in variable names.
    J. Gleixner, Dec 1, 2003
    #2
    1. Advertising

  3. ThERiZla

    Uri Guttman Guest

    >>>>> "JG" == J Gleixner <> writes:

    JG> ahhh... so your code looks exactly like:

    JG> my @outputcreateUser = $telnet->cmd($createUser); print
    JG> @outputCreateUser;

    JG> Case is important in variable names.

    another reason why StuDlyCaps is such a bad idea. it is tricky enough
    getting long names correct (and strict is a must anyway) but adding case
    issues makes it just annoying. i created a copy-word func in emacs long
    ago in my personal perl mode that copies a name and preceding sigil so i
    can paste it elsewhere. makes life lots easier when using vars multiple
    times.

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Dec 1, 2003
    #3
    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. Shuttermutt

    Perl telnet proxy

    Shuttermutt, Sep 3, 2003, in forum: Perl
    Replies:
    0
    Views:
    2,652
    Shuttermutt
    Sep 3, 2003
  2. Vinay Gupta
    Replies:
    2
    Views:
    1,104
    Michael Schlenker
    Jul 27, 2004
  3. CJ
    Replies:
    0
    Views:
    1,823
  4. Jim Isaacson
    Replies:
    5
    Views:
    602
    Default User
    Nov 5, 2004
  5. Carcarius
    Replies:
    0
    Views:
    289
    Carcarius
    Dec 6, 2007
Loading...

Share This Page