ssh not ending (sometimes) from inside a script, why?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh not ending (sometimes) from inside a script, why?
# 1  
Old 09-10-2004
Data ssh not ending (sometimes) from inside a script, why?

Okay I have this script file that runs from cron and most the time it works just find. Except every so often one of the three ssh commands I have in it just doesn't know it's done and that of course causes the whole thing to hang!

The ssh command has executed. I can tell this because the command is as follows

ssh username@hostname "ls /somedirectory" >somedir.file

and a new somedir.file has been created on the machine running the cron script.

Also, when this happens I can use the "kill sshprocessid" command and the cron script will continue, fat dumb and happy!

I figure there is a race condition of some kind going on for the end of command signal and once in awhile it gets missed but.... I just don't know where else to look....

Any ideas???
# 2  
Old 09-16-2004
Question Any Help out there??

Well, I see that people have read my question but have not heard any ideas from anyoneSmilie

It leaves me wondering if I did not write the question well enough so people can understand me or if it's just a problem no one else has had to deal with or .... ?????

Just incase anyone cares, I've posted this question is several different places and got no responses so to get over this issue in my script I'm doing the following:

ssh username@hostname "command to process" >fileforoutput &

This (the "&") makes the command run in the back ground and control comes back to the script (even if the ssh command hangs).

next I sleep 60 seconds, to give the ssh command time to run and then I look for the ssh process and kill it if it's still there.

Not pretty but I think it will work.

I'ld still like to avoid the problem so if anyone out there has a better idea post it Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

School ending Script

Hello beautiful people, I would like to kindly ask you to help me with my school leaving project. Unfortunatelly due to family problems I felt into trouble and I am on able to finish my project due to schedule. I would like to ask you to review this script and give me any hints that you could.... (2 Replies)
Discussion started by: Cerda
2 Replies

2. AIX

Need help on for loop inside ssh

Hi, I am having a file like, #cat file Jun 19 13:08 Jun 19 13:08 Jun 19 13:08 Jun 19 13:14 when I run the below comamnd locally it will work fine, IFS=$'\n'; for i in $(cat file) ;do echo "HI $i" ; done And the output is, HI Jun 19 13:08 HI Jun 19 13:08 HI Jun 19 13:08 HI... (1 Reply)
Discussion started by: sumanthupar
1 Replies

3. Shell Programming and Scripting

Repetitive ending of script

Hi, I am quit satisfied with this scrtipt and really don't want to change anything but the end. I get a repetitve option when I want to "quit" and don't know why. What am I missing? When I press q to quit with this script, I get an EXTRA "Enter " How do I correct this so that when I press... (1 Reply)
Discussion started by: jefferj54
1 Replies

4. Shell Programming and Scripting

UNIX script abruptly ending due to ssh command

Below UNIX script abruptly ends while reading second line from file. When I comment 'ssh' command the script works as expected. I think I will have to run ssh command in a different process, but haven't got a handle yet as regards to how to do that. Any help in resolving this problem is highly... (1 Reply)
Discussion started by: jeeteshkc
1 Replies

5. Shell Programming and Scripting

Using ssh command inside a script

Hi, I have a script file in server A. Inside the script file, I first have a ssh command that will connect to a remote server B. In the same script file itself, I have a sequence of commands that has to be run in server B. I am embedding these commands in the script file that I have in server A.... (2 Replies)
Discussion started by: mick_000
2 Replies

6. Shell Programming and Scripting

Problem using ssh inside script

Hi, When runnin the following script it complte successfully with out any problem #!/bin/sh SERV="crm1" for s in $SERV do export WebLogicSessions=`ssh psoft@$s "cd /software/psoft/scripts ; ./getweblogicsessions.sh crm1 8001 PIA | awk '{print $1}' ` echo "Checking number of... (0 Replies)
Discussion started by: yoavbe
0 Replies

7. Shell Programming and Scripting

ssh inside a for loop

Hi, The requirement is to ssh to unix servers and oracle databases, to perform some monitoring activity. I'm using shell script to perfom this. I pass the server details and database to a variable ... SERVERS="SERVER1 SERVER2 SERVER3" DATABASE="DB1 DB2 DB3" for i in $SERVERS do ssh... (2 Replies)
Discussion started by: senthil3d
2 Replies

8. Shell Programming and Scripting

Ending a script

Hi all, I am trying to end a Menu script. Can people suggest various methods please? At the moment I am doing: quit=n while do ...Code Code Code... read userinput case $userinput in q|Q) quit=y;; esac done But this doesn't seem to work every time, occasionally it will work,... (6 Replies)
Discussion started by: mikejreading
6 Replies

9. Shell Programming and Scripting

looping a array inside inside ssh is not working, pls help

set -A arr a1 a2 a3 a4 # START ssh -xq $Server1 -l $Username /usr/bin/ksh <<-EOS integer j=0 for loop in ${arr} do printf "array - ${arr}\n" (( j = j + 1 )) j=`expr j+1` done EOS # END ========= this is not giving me correct output. I... (5 Replies)
Discussion started by: reldb
5 Replies

10. Shell Programming and Scripting

Ending script after a specified time.

Hi All, I am having a script, which run fine. But what I want to do is that the script should run for specified time and terminate then ( say for a minute). Can somebody help me for this. I would be greatful. Thanks, Aru (8 Replies)
Discussion started by: aarora_98
8 Replies
Login or Register to Ask a Question