Sponsored Content
Top Forums Shell Programming and Scripting script hangs when a remote server is down Post 302143834 by bakunin on Sunday 4th of November 2007 01:36:32 PM
Old 11-04-2007
Do you know how long the commands on the remote machine will approximately take? If so you could run the ssh-command in the background and then use sleep to let pass this time (plus some for contingency). If the command the still runs, you consider it to be hanging and kill it, if it has finished it is ok. You can use the "jobs" built-in ksh command to check the status of the job.

We suppose the commands you want to run remotely will take 20 seconds approximately. We add 10 seconds just to be sure and put the IP adress of the host to be contacted in a variable which is read in a loop :

Code:
.... < your script >....
cat list_of_ipadresses | while read ipadress ; do
     ssh  ssh $ipadress "<...commands ..>" &
     sleep 30
     jobs > /dev/null
     if [ $(jobs -p %s 2>/dev/null| wc -l) -ge 1 ] ; then
          print - "an error occurred contacting $ipadress
          kill %1
     else
          print - "success contacting $ipadress"
     fi
done
...

The first "jobs" statement is there to clear the display of all the "done"-messages if backgroup jobs already terminated during the sleep-statement.

bakunin
 

10 More Discussions You Might Find Interesting

1. Linux

Script hangs on the unix server

We have a unix script scheduled to execute once in a day, some times it hangs on the server and never performs its operations, we need to manually kill the process and re-start that script, is there any way to have notification when the script hangs on the server. Thanks & Regards, Murthy. (3 Replies)
Discussion started by: Ramana Murthy
3 Replies

2. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies

3. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

4. Programming

Expect script to run a Shell script on remote server

Hi All, I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands. spawn ssh $uid@$host expect "password:" send "$password\r" expect "*\r" send... (2 Replies)
Discussion started by: yashwanthsn
2 Replies

5. Shell Programming and Scripting

Need help on how to exit a script run on a server from a remote server

hi, I am using the below line to run a script from remote server(say server A) to another server(say server B). ssh username@servername ksh script name. The issue is the script logs into server B, executes the script on server B, transfers the file to server A but does not exit from... (4 Replies)
Discussion started by: yohasini
4 Replies

6. Solaris

Script to get files from remote server to local server through sftp without prompting for password

Hi, I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script. Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies

7. Shell Programming and Scripting

How to Append the output of a script running in remote server to a file in local server?

Hi guys, So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies

8. Shell Programming and Scripting

Sudo connect to a remote server and execute scripts in remote server

Hello Every one!! I am trying to write a shell script which will connect to a remote server and execute scripts which are at a certain path in the remote server. Before this I am using a sudo command to change the user. The place where I am stuck is, I am able to connect to the... (6 Replies)
Discussion started by: masubram
6 Replies

9. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

10. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies
KA-FORWARDER(8) 					       AFS Command Reference						   KA-FORWARDER(8)

NAME
ka-forwarder - Forward AFS Authentication Server requests to another server SYNOPSIS
ka-forwarder [-p <port>] <server>[/<port>] [...] DESCRIPTION
ka-forwarder listens for requests for an AFS Authentication Server and forwards them to a remove fakeka server. fakeka is a server that answers AFS Authentication Server protocol requests using a regular Kerberos KDC and is provided with some Kerberos 5 implementations. fakeka has to run on the same host as the Kerberos KDC, however, and AFS clients send all native AFS authentication requests to the AFS database servers. If you don't want to run your Kerberos KDCs and your AFS database servers on the same host, run ka-forwarder on the AFS database servers and point it to fakeka running on the Kerberos KDCs. ka-forwarder takes one or more servers to which to forward the requests. The default port on the remote server to which to forward the command is 7004, but a different port can be specified by following the server name with a slash ("/") and the port number. If multiple servers are given, ka-forwarder will send queries to each server in turn in a round-robin fashion. CAUTIONS
Due to the way that ka-forwarder distinguishes from client requests and server responses, any messages from one of the servers to which ka- forwarder is forwarding will be considered a reply rather than a command and will not be forwarded. This means that the servers running fakeka will not be able to use native AFS authentication requests and rely on ka-forwarder to send the requests to the right server. ka-forwarder does not background itself. It should either be run in the background via the shell, or run via the Basic OverSeer Server (see bosserver(8)). OPTIONS
-p <port> By default, ka-forwarder listens to the standard AFS Authentication Server port (7004). To listen to a different port, specify it with the -p option. EXAMPLES
Forward AFS Authentication Server requests to the fakeka servers on kdc1.example.com and kdc2.example.com: % ka-forwarder kdc1.example.com kdc2.example.com & Note the "&" to tell the shell to run this command in the background. PRIVILEGE REQUIRED
ka-forwarder only has to listen to port 7004 and therefore does not require any special privileges unless a privileged port is specified with the -p option. SEE ALSO
bosserver(8), fakeka(8), kaserver(8) COPYRIGHT
Copyright 2006 Russ Allbery <rra@stanford.edu> This documentation is covered by the IBM Public License Version 1.0. This man page was written by Russ Allbery for OpenAFS. OpenAFS 2012-03-26 KA-FORWARDER(8)
All times are GMT -4. The time now is 06:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy