LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   timeout option in ssh or rsh?? (https://www.linuxquestions.org/questions/linux-newbie-8/timeout-option-in-ssh-or-rsh-757664/)

kdelover 09-25-2009 02:24 AM

timeout option in ssh or rsh??
 
Hi,

Is any one aware of timeout option for rsh or ssh? I need it for a script.All i want is to to rsh\ssh a workstation and exit it from it after the mentioned time:).

Thanks for the help!

Tinkster 09-25-2009 02:38 AM

I'm not aware of such an option. Guess you'll need to write a wrapper that starts your
script and back-grounds it, and then shoots it dead.

lutusp 09-25-2009 03:31 AM

Quote:

Originally Posted by kdelover (Post 3696478)
Hi,

Is any one aware of timeout option for rsh or ssh? I need it for a script.All i want is to to rsh\ssh a workstation and exit it from it after the mentioned time:).

Thanks for the help!

1. Read the user's inputs line by line and reset a counter at each entered line.

2. Have an interval timer increment the counter, read the result, and exit the session once the inactive time criterion is met.

To do this, you need threads, so Bash is out. Use Ruby, Python, something that supports threads and is reliable. The user would not see the interaction in any way out of the ordinary -- Ruby or Python would present the user's entries and the server's replies in the normal way.

It would be nice if the script provided a warning before unplugging the user, who might have started a long, critical process that shouldn't be interrupted.

kdelover 09-25-2009 03:32 AM

Thanks for the reply :) can you tell me more regarding that

lutusp 09-25-2009 03:53 AM

Quote:

Originally Posted by kdelover (Post 3696535)
Thanks for the reply :) can you tell me more regarding that

Not really. Not without writing it for you. Just learn how to write Ruby or Python code, then write your own.

chrism01 09-25-2009 07:33 AM

bash TMOUT setting in /etc/profile
http://linuxgazette.net/issue58/sharma.html

rhel5 01-10-2010 01:56 PM

Please Help
 
How do you add timeout option for RSH command???

I have a script that runs some network tests such as traceroute over rsh.

But when rsh attempts to establish a connection... it just hangs there.

So my script will never finish and gets stuck at the command with rsh.

I am using the following command in my script:

rsh server1 -l user1 -t 120 traceroute 192.168.1.245

The above command should have timed out in 2 mins when it can't connect.

Thanks!

alghazi 01-10-2010 06:28 PM

How about using ssh:
user ssh -o ConnectTimeout=120 server

chrism01 01-10-2010 06:30 PM

If you wrote it in Perl (or used a Perl wrapper) you can use the ARLM signal

Code:

eval {
    alarm(3600);
    # long-time operations here
    alarm(0);
};

if ($@) {
    if ($@ =~ /timeout/) {
                            # timed out; do what you will here
    } else {
        alarm(0);          # clear the still-pending alarm
        die;                # propagate unexpected exception
    }
}

or see http://perldoc.perl.org/functions/alarm.html

rhel5 01-10-2010 09:22 PM

Thanks alghazi & chrism01

SSH has been disabled. So I am stuck rsh/rlogin or telnet.

As for the PERL, I wrote my script in bash. =(

I have PERL as my next skill to pick up list.

Is there any other ideas?

chrism01 01-11-2010 12:09 AM

If you insist on using bash, Tinkster's soln (post #2) is the way to go


All times are GMT -5. The time now is 10:45 PM.