Visit Our UNIX and Linux User Community


RSH Timeout


 
Thread Tools Search this Thread
Operating Systems Linux RSH Timeout
# 1  
Old 09-27-2009
RSH Timeout

Hi All

I have a nice little script that i have written in Perl, in it use RSH ( yes i know it is i should being using ssh, but it i secure network it is being run on) the idea of the script it that it will RSH into a machine and then follow out a command, the problem i am running into is if the RSH deamon for what ever reason as stopped working on the machine, the script will keep trying to accsess the machine for a few mins and then move onto the next, is there a way to add a timeout, so if the connect is not made in say 30 seconds it will move on

thanks


John
# 2  
Old 09-27-2009
I would try to do the following (Im a beginner Smilie ) -

Code:
CHK=`ssh2 -q <IP> "ps -ef | grep rshd | grep -v grep"`  

if [ $CHK -eq 0 ]; then
    sleep 30
    CHK=`ssh2 -q <IP> "ps -ef | grep rshd | grep -v grep"`
    
   if [ $CHK -ne 0 ];then
      //call your script here
   else
     //rshd in remote sys is not up
    //do what you want to
   fi
else
  //rshd running - call your script here too
fi

# 3  
Old 09-27-2009
i could be wrong but is that not just using ssh instead to check to make sure rsh is running??

I do not really care that it is not running, i just want the script to pass over that machine and carry on with the other machines in the list.
thanks

John
# 4  
Old 09-27-2009
rsh itself apparently doesn't support a timeout. If you've got netcat available, you could use this
Code:
netcat -z -w 3 remote 514

and check $?.
Or use IO::Socket::INET to open a connection yourself with a timeout and check that.

Previous Thread | Next Thread
Test Your Knowledge in Computers #322
Difficulty: Easy
HTML stands for Hypertext Markdown Language.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Timeout in shellscripting

#!/bin/sh for ip in $(cat /root/Desktop/ftp.txt) do HOST=$ip USER='bob' PASS='bob' ftp -n $HOST <<EOF user bob bob EOF echo "$ip" done the Above code i want to use check and verify login works on multiple ftp servers on my network. However the ftp servers are dynamic in setup... (5 Replies)
Discussion started by: Noledge
5 Replies

2. Shell Programming and Scripting

EXCEPT timeout problem

i am trying to write an except script to ssh into a list of devices and run some commands, and i came across this problem, not every device is alive, which breaks the script, my script looks like this #!/usr/bin/expect # set defaults set... (1 Reply)
Discussion started by: fedora
1 Replies

3. UNIX for Dummies Questions & Answers

rsh and timeout

hi, i have many ksh shell scripts running "rsh" command and sometimes the remote host doesn't answer so the rsh command doesn't return data and the script waits. How can i modify this to have a forced return to continue my script , a kind of controlled timeout ? thanks in advance... (0 Replies)
Discussion started by: Nicol
0 Replies

4. Shell Programming and Scripting

how to set timeout?

When I run a script where the 1st parameter is ip address ftp -n -i -v $1 I hang here if the ip is wrong how to set a timeout something like if (20s not complete "ftp -n -i -v $1") then echo "error" fi Thanks a lot. (14 Replies)
Discussion started by: uativan
14 Replies

5. Shell Programming and Scripting

Can we timeout cd command

Hi All, I want to know whether we can timeout the cd command in unix. If we can how is it implemented? Suppose cd command hangs can we timeout the command. Please help (9 Replies)
Discussion started by: dipashre
9 Replies

6. Filesystems, Disks and Memory

timeout problem

Hi can anyone help with the following:- when sending large e-mails via a ssh session the job always times out every 5 min before the mail is sent, this means that a user has to tap a key to stop it timming out. Is there a way to stop this from happening. Numpty (4 Replies)
Discussion started by: numpty
4 Replies

7. Solaris

About the Timeout

Hello everyone I am a new one,I want to know how to get the solaris force the loginer out if he do not in a time thanks (4 Replies)
Discussion started by: lyh003473
4 Replies

8. HP-UX

timeout

How can I kick a user out after being idle for a certain amount of time, would prefer not to use scripts, will TMOUT work on HP-UX? (5 Replies)
Discussion started by: csaunders
5 Replies

9. UNIX for Dummies Questions & Answers

sendmail timeout

Just implemented sendmail on rh9. The clients are timing out or dropping a connection to the server. What's up? I've been tweaking, but no noticable change. They can recieve and send mail, but it errors out consistently and then reconnects fine. Am I missing a timeout setting in the cf file? ... (1 Reply)
Discussion started by: benzo
1 Replies

10. UNIX for Dummies Questions & Answers

Timeout Error

I'm getting a error on a old SPARC Station 5 system. The HDD I am using in internal 18GB. Everything use to work, and well wont now. The error I am getting is in bootup. The error is 'Timeout waiting for ARP?RARP packet error'. Anyone got any idea how I can fix this? I'm not sure... (4 Replies)
Discussion started by: merlin
4 Replies

Featured Tech Videos