LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2009, 02:24 AM   #1
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
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!
 
Old 09-25-2009, 02:38 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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.
 
Old 09-25-2009, 03:31 AM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by kdelover View Post
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.
 
Old 09-25-2009, 03:32 AM   #4
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
Thanks for the reply can you tell me more regarding that
 
Old 09-25-2009, 03:53 AM   #5
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by kdelover View Post
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.
 
Old 09-25-2009, 07:33 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
bash TMOUT setting in /etc/profile
http://linuxgazette.net/issue58/sharma.html
 
Old 01-10-2010, 01:56 PM   #7
rhel5
Member
 
Registered: Mar 2009
Location: Bay Area, CA
Distribution: Redhat Enterprise Linux
Posts: 59

Rep: Reputation: 15
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!
 
Old 01-10-2010, 06:28 PM   #8
alghazi
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
How about using ssh:
user ssh -o ConnectTimeout=120 server
 
Old 01-10-2010, 06:30 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
Old 01-10-2010, 09:22 PM   #10
rhel5
Member
 
Registered: Mar 2009
Location: Bay Area, CA
Distribution: Redhat Enterprise Linux
Posts: 59

Rep: Reputation: 15
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?
 
Old 01-11-2010, 12:09 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsh -l option permission denied error kgopal30 Linux - Server 1 09-28-2011 09:06 PM
rsh / ssh woes kevingpo Fedora 11 04-26-2007 06:46 AM
rsh witl -l option consty Linux - General 2 08-28-2005 05:07 AM
what is rsh and ssh ztdep Linux - Networking 2 07-17-2005 05:28 AM
rsh/ssh from Linux to Solaris sttaft Solaris / OpenSolaris 7 06-16-2004 06:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration