Please help a complete newbie

Discussion in 'Perl Misc' started by ZoloftGuy, Jul 29, 2004.

  1. ZoloftGuy

    ZoloftGuy Guest

    The goal is to reboot and or shutdown a Nortel Contivity box with PERL
    and the Telnet Script.

    use Net::Telnet ();

    ###Prompt is "$"

    $t = new Net::Telnet (Timeout => 30, Prompt => '/[\$]/');
    $t->input_log('input.txt');
    $t->output_log('output.txt');
    $t->open("nortelcontivity");
    $t->waitfor('/Login:/');
    $t->print("admin");
    $t->waitfor('/Password:/');
    $t->print("thepassword");
    $t->waitfor('/CES\>/');
    $t->print("en");
    $t->waitfor('/Password:/');
    $t->print("thepassword");
    $t->print("reload restart");
    @output1 = $t->cmd('y');
    print @output1;
    $t->close;

    When I issue the reload restart commmand, this message pops up from
    the Contivity: (exactly like this, I pulled this from input log.)
    %Proceed with reload? (y/n)

    I then do this:
    @output1 = $t->cmd('y');
    print @output1;
    $t->close;

    It works, the box reboots, but I get this error:

    pattern match read eof at C:\temp\yo.pl line 18

    Feel free to flame me, I admit, I don't know what the heck I am doing.

    Thanks
     
    ZoloftGuy, Jul 29, 2004
    #1
    1. Advertisements

  2. Please but the subject of you post in the Subject of your post.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
     
    Brian McCauley, Jul 29, 2004
    #2
    1. Advertisements

  3. ZoloftGuy

    ZoloftGuy Guest

    Here is the solution, in case anyone needs it. Thanks to Joe Smith,
    this was resolved in a previous thread.

    I am able to reproduce the error report on Linux using a fake `en`.
    Here's what it looks like when using $t->input_log('-');
    $t->output_log('-');

    linux% perl yo.pl
    Red Hat Linux release 9 (Shrike)
    login: admin
    admin
    Password: thepassword

    Last login: Sat Jul 31 23:08:00 from localhost
    CES>en
    en
    Password: thepassword
    reload restart
    y
    thepassword
    reload restart
    y
    Password accepted
    command is reload restart (y/n)
    bin/en: faking a reset by killing parent pid 11655
    [1] 11688
    logout
    pattern match read eof at yo.pl line 18
    linux%
    Since you did not provide a prompt for $t->cmc('y'), Net::Telnet was
    using
    the Prompt set in the initial connection, '$'. After sending the 'y',
    it
    was waiting for a dollar sign, but instead got an eof because the
    server
    closed the telnet connection during its reset.

    If you don't want to see that message, change $t->errmode() just
    before cmd().

    $t->errmode(sub {die @_ unless $_[0] =~ /eof/}); # Be quiet about
    getting eof
    @output1 = $t->cmd('y'); # 'reset' causes telnet eof

    -Joe
     
    ZoloftGuy, Aug 3, 2004
    #3
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.