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

Hi all; I'm having a problem with Net::Telnet connecting and running a process on a VMS machine. It is the good old "command timed-out" error which is giving me a headache.

On the VMS machine, my process produces output like this:

%WEATHERFILE-I-OPENFILE, Opening Input File: SYS$Weather_Data:20010301 +.WST %WEATHERFILE-I-OPENFILE, Opening Input File: SYS$Weather_Data:20010302 +.WST . . . etc Here is my perl code: use strict; use Net::Telnet; my $name = 'NAME'; my $passwd = 'PASSWORD'; my $telnet = Net::Telnet->new( Input_Log => "input.log", Output_Log => "output.log", Host => "HOST", Timeout => "20" ); $telnet->login(Name => $name, Password => $passwd, Prompt => '/HOST/i'); $telnet->cmd("$mycommand"); $telnet->cmd("lo"); #logout $telnet->close; exit;
As I understand it, cmd does not take any action UNLESS it sees the prompt (HOST$ in this case). If it doesn't see the prompt, the timeout call comes into affect. Is this correct?

In order to aviod the timeout, I could just say that I know how long it takes to process each file on the VMS machine and scale this by the number of files I want to process (and use this as the timeout value).

Is there another way of doing this?

Thanks!

Regards,
Stacy.

Replies are listed 'Best First'.
Re: Unix - VMS and Net::Telnet
by LD2 (Curate) on Mar 28, 2001 at 08:10 UTC
    It's possible I'm misunderstanding your question, but the cmd() function uses prompt to determine when a command has finished. It's important that the prompt is set correctly or else it will timeout. Prompts are usually set to tcsh, bash, sh, etc.. shell prompts. To read more about it, please view: Net::Telnet
      My prompt is set correctly... Using $telnet->cmd("$command") still returns "command timed-out" even though the process is still running on the remote machine...
        Using truss, successfull output is as follows: time() = 985758526 poll(0xEFFFC790, 1, 67000) (sleeping...) poll(0xEFFFC790, 1, 67000) = 1 When the program fails, the command on the remote machine is still not finished, but the output from truss is: time() = 985758587 poll(0xEFFFC790, 1, 6000) (sleeping...) poll(0xEFFFC790, 1, 6000) = 0 So the difference is the "poll =" expression. What does this mean? (BTW, Timeout was set to 60 seconds).
Re: Unix - VMS and Net::Telnet
by TrinityInfinity (Scribe) on Aug 13, 2001 at 23:33 UTC
    You are correct in that if NetTelnet doesn't see the prompt, it will never issue the command. I had two problems when using that module to telnet from my Solaris system to the Vax,
    1) - commands timing out
    2) - never getting the prompt

    For our vax, the prompt is $ - which I thusly defined as the prompt. However, set your script to make the dump log for Net::Telnet, and look thru the content. I found that somehow my $ sign was eaten in the translation, and had to define it as $match = '/\[0c/'; After that, I've always caught the prompt correctly.

    Another problem I had that caused timeouts was the error mode of the module.The default errmode is die if I recall correctly, which kept throwing the monkey wrench in my script. My code to avoid that looked like
    $vax = new Net::Telnet(Prompt => $match);<br> $vax->errmode("return");

    While these may not exactly fit your problem, and seeing as how I'm answering this several months late, I hope it helps at all in some small matter. I'm just glad to know enough to comment on something now! =)