Net::Telnet prompt problem

Discussion in 'Perl Misc' started by colintelfer@hotmail.com, Apr 13, 2005.

  1. Guest

    I get this error when running my small test program...

    timed-out waiting for login prompt

    ....
    $host = '192.168.100.251';
    $port = '24';
    $username = 'admin';
    $password = '';
    $prompt = '/User:/';
    $session = new Net::Telnet
    (
    Timeout => 5,
    Prompt => $prompt
    );

    $session->input_log("inputlog.txt");
    $session -> open(Host => $host,Port => $port);
    $session -> login($username, $password);
    ....

    Here is the ouput from inputlog.txt:

    (Sys)
    User:

    I am guessing there is a problem with prompt, but I have tried a few
    different matches without success...

    Any help?

    Thanks!
    , Apr 13, 2005
    #1
    1. Advertising

  2. Maxim Guest

    wrote:
    > I get this error when running my small test program...
    >
    > timed-out waiting for login prompt
    >
    > ...
    > $host = '192.168.100.251';
    > $port = '24';
    > $username = 'admin';
    > $password = '';
    > $prompt = '/User:/';
    > $session = new Net::Telnet
    > (
    > Timeout => 5,
    > Prompt => $prompt
    > );
    >
    > $session->input_log("inputlog.txt");
    > $session -> open(Host => $host,Port => $port);
    > $session -> login($username, $password);
    > ...
    >
    > Here is the ouput from inputlog.txt:
    >
    > (Sys)
    > User:
    >
    > I am guessing there is a problem with prompt, but I have tried a few
    > different matches without success...
    >
    > Any help?
    >
    > Thanks!
    >


    Prompt has no effect on login function. Well, it does, but not on
    username/password command-line patterns.
    login function waits for patterns like this:

    /login[: ]*$/i
    /username[: ]*$/i
    /password[: ]*$/i

    You have the prompt "User:", that is why login times out; Try using
    print/waitfor instead. It can be something like this:
    $session->waitfor('/User:/')
    $session->print($username);
    $session->waitfor('/password:');
    $session->print($password);
    $session->waitfor($cmd_line_prompt);

    ....
    and so on.

    Hope this Helps a little.

    --
    Maxim Sloyko
    Maxim, Apr 14, 2005
    #2
    1. Advertising

  3. Guest

    Helps a lot!

    Thanks this works.
    , Apr 14, 2005
    #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. Pete Johansen

    NET::Telnet prompt regular expression

    Pete Johansen, May 5, 2004, in forum: Perl
    Replies:
    0
    Views:
    1,142
    Pete Johansen
    May 5, 2004
  2. Carcarius
    Replies:
    0
    Views:
    293
    Carcarius
    Dec 6, 2007
  3. Replies:
    1
    Views:
    129
  4. Replies:
    0
    Views:
    77
  5. Replies:
    4
    Views:
    233
Loading...

Share This Page