client/server using Net::Telnet fails under certain conditions. Help please

Discussion in 'Perl Misc' started by Robert, Sep 11, 2003.

  1. Robert

    Robert Guest

    I wrote a server that listens for an input array of 1 or more elements. It
    conducts a conditional loop looking for key patterns in array element [0].
    Based upon the match the server executes a predetermined function e.g. if
    ($in[0] =~ /pattern/) { do something }. It works great when I telnet to the
    assigned port on the host the server is listening to. That is,

    telnet hostname 12000
    fs
    <execute a df from server>

    When I run my client some of the commands work, $shell->print('some
    command'), and some don't. I have tried closing the socket and reopening
    it, turned on all the error messages I know about, print to the LOG files.
    What I have determined is that the call to

    open(CMD,"| ps -ef") or print LOG "ps failed $!\n"; fails to either
    work (which I doubt since the log file doesn't have any entires for that
    failure or the $shell->getlines(); is not receiving any input. Remember, it
    works fine when I telnet manually. Any ideas as to why it is failing.
    Thanx in advnace.

    ______END_____


    $shell =
    Net::Telnet->new(Host=>$host,Port=>$port,Timeout=>60,Errmode=>'return');
    $shell->input_log($logfile);
    $shell->dump_log($dumplog);
    $fs_array = get_fs(); <<<<<<<<<<<< goes to server to execute and return a
    df. Works fine!

    ($filesystems,$h_lvols) = clean_data($fs_array); <<<<<<<<< Not a
    Net::Telnet sub.

    $filesys = select_fs($filesystems); <<<<<<<< not a Net::Telnet sub.

    ($startd,$stopd) = select_dates(); <<<<<<<<<< not a Net::Telnet sub.

    begin_extract($extract,$startd,$stopd); <<<<<< Net::Telnet sub. works
    when I take out the following while loop and replace with sleep for 40.
    $line = $shell->lastline;
    print "This is lastline 1 $lastline\n";
    $result = $shell->errmsg;
    print "Error msg 1 $result\n";

    $shell->close();
    $shell =
    Net::Telnet->new(Host=>$host,Port=>$port,Timeout=>60,Errmode=>'return');
    while (1) {
    print "XXX\n";
    $shell->print("psef");
    @psarray = $shell->getlines(); <<<<<<<<<<<<<< seems to fail here in that
    nothing is returned to @psarray.
    $line = $shell->lastline;
    print "This is lastline 2 $lastline\n";
    $result = $shell->errmsg;
    print "Error msg 2 $result\n";
    chomp(@psarray);
    if (grep { /extract/ } @psarray ) {
    print "grep match\n";
    sleep 5;
    } else {
    print "last ---*\n";
    last;
    }
    }
     
    Robert, Sep 11, 2003
    #1
    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. PJ6
    Replies:
    8
    Views:
    2,077
  2. Jim Isaacson
    Replies:
    5
    Views:
    607
    Default User
    Nov 5, 2004
  3. Simon
    Replies:
    1
    Views:
    289
    Yuriy Solodkyy
    Jun 11, 2007
  4. Simon
    Replies:
    1
    Views:
    122
    Yuriy Solodkyy
    Jun 11, 2007
  5. Carcarius
    Replies:
    0
    Views:
    302
    Carcarius
    Dec 6, 2007
Loading...

Share This Page