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

Well, Net::Telnet() has served me well, but I need it to go *much* faster than it already is.
My script connects to a Vax machine, and issues whatever commands are needed, but I find that Net::Telnet() is running until the command timeout, not until the matching prompt returns. This has made me force my commands to have 40-60 second timeouts in order to ensure none of my info gets cut off. Using some key placements of 'localtime' to record what happens when, the example below will run for 31, 31, and 56 seconds respectively, even if the command is brief and finishes in 10-15 seconds.

I'm desperate to get this trimmed down in time, but don't know enough of the code's workings on my own to do it.
I've posted a few lines below... if someone prefers to see what's happening.
$match = '/\[0c/'; $matchop = $match; $hostname = 'silly.vax.machine'; $vax = new Net::Telnet(Prompt => $match); $vax->errmode("return"); $vax->open($hostname); #$vax->dump_log($dumplog); $start = localtime(); $vax->login(Name => $login, Password => $password) || die "cannot logi +n to $hostname"; $vax->cmd(String => $string1, Timeout => 30, Prompt => $matchop); $vax->cmd(String => $string2, Timeout => 30, Prompt => $matchop); $vax->cmd(String => $string3, Timeout => 55, Prompt => $matchop);
... you get the picture. Is there something I'm doing wrong or misinterpreting when reading the CPAN documentation about matching and timeouts?

Replies are listed 'Best First'.
Re: Any Net::Telnet() gurus?
by traveler (Parson) on Aug 22, 2001 at 20:25 UTC
    It sounds as though you are not looking for the right prompt. Maybe you should try to print the data returned in a fashion where you can see the actual characters the VAX sends back to you. I suggest using the interactive telnet client and trying a simple command with "toggle netdata" set. (To set a telnet option, type the escape character, normally control-], then the command at the prompt.)

    HTH, --traveler

Re: Any Net::Telnet() gurus?
by the_slycer (Chaplain) on Aug 22, 2001 at 23:47 UTC
    When dealing with vaxen and Net::Telnet it is much easier to make use of $t->print and $t->waitfor than it is to use $t->cmd.

    I've been down the ugly route that you are headed and the above is what I have determined.