gonzo has asked for the wisdom of the Perl Monks concerning the following question:

Hi, this is probably a simple question I have modified the example perl file to create a telnet application. This works just great for things that give back 1 answer. For example the UNIX box I try to telnet to gives me the expected output from the df command, and after that has finished I can enter subsequent commands. The problem I have is with things like ping or anything that has a constant output, they will just return no output. I won't post the code, as it is a couple of pages. If you think you may be able to help me that would be great. thanks in advance Matt

Replies are listed 'Best First'.
Re: Net::Telnet.pm Ping doesn't work
by MZSanford (Curate) on Nov 16, 2001 at 15:28 UTC
    hmmm, this is covered rather in-depth in "Network Programing with Perl" by Lincold Stein. The problem is usually that you read using somthing similar to <code lang="perl"><SOCKET></code>, which only read one line, and the rest is queued. Usually the way around this is to use un-buffered reads. (see Super Search for node on the subject). Without seeing code, not much else i can say.

    Update : Thinking, if Net::Telnet is used, you really don't have control over buffering. Are you using <code lang="perl">$telnet->cmd()</code> ? If so, are you asking it to return and array or a scalar ?
    i had a memory leak once, and it ruined my favorite shirt.
Re: Net::Telnet.pm Ping doesn't work
by alien_life_form (Pilgrim) on Nov 16, 2001 at 20:32 UTC
    Greetings,

    I am not sure I understand this completely.
    Are you asking the remote box to perform the 'ping' command? (And what does it mean its output is constant?) If so are you sending a limited number of packets (-c, I think) or are you doing an open ended ping? In this last case, I have a feeling that Net::telnet->cmd will not return until the command is over (i.e. never).
    Cheers,
    alf


    You can't have everything: where would you put it?