in reply to Re: Unix - VMS and Net::Telnet
in thread Unix - VMS and 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...

Replies are listed 'Best First'.
Re: Re: Re: Unix - VMS and Net::Telnet
by maderman (Beadle) on Mar 28, 2001 at 11:02 UTC
    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).
      I fixed the problem by multiplying the number of input files by 60 and using this as my timeout value... The script below now works:
      use strict; use Net::Telnet; use Net::FTP; use Time::Local; my $name = 'USER'; my $passwd = 'PASSWORD'; my $host = 'HOST'; my $prompt = '/MACHINENAME\$/'; my($sdate,$edate,$outfile) = @ARGV; $outfile = uc($outfile); #VMS puts files in uppercase my $command = 'some command'; # Assume each file in a specified date range will take 60 # seconds to process. Multiply # this by 60 to get the timeout value. Large, but we don't # have to deal with timeout problems #Work out how many days in specified range: my($sday,$smon,$syear) = split('-',$sdate); my($eday,$emon,$eyear) = split('-',$edate); my $time1 = timelocal(0,0,0,$sday,$smon,$syear); my $time2 = timelocal(59,59,23,$eday,$emon,$eyear); my $difference = $time2 - $time1; my $days = sprintf("%3.0f", $difference / (60*60*24) ); my $timeout = $days * 60; my $telnet = Net::Telnet->new( Prompt => "/$prompt/", Input_Log => 'input.log', Output_Log => 'output.log', Host => $host, Timeout => $timeout ); $telnet->login(Name => $name, Password => $passwd, Prompt => "/$prompt/", ); $telnet->cmd($command); $telnet->print("lo"); $telnet->close; my $ftp = Net::FTP->new("$host", Debug => 1); $ftp->login($name,$passwd); $ftp->get("$outfile.CSV"); $ftp->delete("$outfile.CSV"); $ftp->quit; exit;