For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2007 > Telnet exits after time out









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Telnet exits after time out
Lakshmi Sailaja

2007-07-27, 6:59 pm

Hi,

I am logging to a remote session using telnet. I am calling a command to run
an exe. This exe sometimes runs fast and at times take a couple of minutes
depending on the objects.

The problem that I am facing is:
While creating the telnet object, I specify the time out. If the exe that am
running is taking more time than that specified, it is exiting. If I don't
specify the timeout, it exits in 10 sec. Below is my code snippet:
****************************************
*****************************
my $telnet = Net::Telnet->new(HOST => "$SERVER",
TIMEOUT => 120) or die $!;
$telnet->login($USER,$USER);
$telnet->cmd("cd patches/$PATCHID");
$telnet->cmd("buildforms >>$FRLLOG");
****************************************
*****************************

What is the solution? Is there a way that I don't specify the time out value
and let it run until the exe completes its execution?

Thanks & Regards,
Lakshmi
952-833-1220

Chas Owens

2007-07-27, 6:59 pm

On 7/27/07, Lakshmi Sailaja <lakshmi.sailaja@supersolution.com> wrote:
snip
> What is the solution? Is there a way that I don't specify the time out value
> and let it run until the exe completes its execution?

snip

You should never disable the timeout. If you do then there is a
chance your program will hang forever. The correct solution is change
the architecture. Instead of running the program directly and waiting
for it to finish you should run the program in the background on the
remote machine. Then the program on the local machine should sleep
for a few seconds, check to see if the remote program is finished*,
then sleep again, etc until the remote program is done.

* how you go about doing this is system and program dependent. The
easiest way is to have the program create a file when it is done. If
you can't modify the remote program then wrap it with either shell or
batch code as necessary.
Lakshmi Sailaja

2007-07-27, 6:59 pm

Thanks for the input. Will try it out and see!!

Thanks & Regards,
Lakshmi
952-833-1220

-----Original Message-----
From: Chas Owens [mailto:chas.owens@gmail.com]
Sent: Friday, July 27, 2007 12:47 PM
To: lakshmi.sailaja@supersolution.com
Cc: beginners@perl.org
Subject: Re: Telnet exits after time out


On 7/27/07, Lakshmi Sailaja <lakshmi.sailaja@supersolution.com> wrote:
snip
> What is the solution? Is there a way that I don't specify the time out

value
> and let it run until the exe completes its execution?

snip

You should never disable the timeout. If you do then there is a
chance your program will hang forever. The correct solution is change
the architecture. Instead of running the program directly and waiting
for it to finish you should run the program in the background on the
remote machine. Then the program on the local machine should sleep
for a few seconds, check to see if the remote program is finished*,
then sleep again, etc until the remote program is done.

* how you go about doing this is system and program dependent. The
easiest way is to have the program create a file when it is done. If
you can't modify the remote program then wrap it with either shell or
batch code as necessary.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com