Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remsh not finishing 2

Status
Not open for further replies.

risby

Programmer
Feb 27, 2002
84
Peeps

I have a Korn shell script that runs on an HP-UX machine. It loops over a set of machines using remsh to log on to each machine, as a specified user, and then runs a sequence of commands/scripts.

Unfortunately it only executes the first sequence (it only visits the first machine): I can see that it successfully executes everything from the final script in the sequence but then it just hangs. In the original script the next thing to execute is a test on the remsh return status followed by one print or another saying whether it successfully connected.

(I know this is just whether the remsh connection is successful, not the status of the last command executed remotely; the point is the original script should write out something when remsh finishes but nothing more is printed so remsh has not finished.)

I have used the -n option on the remsh command because the man page says it can sometimes get its local and remote stdin confused (or summat like that). It made no difference whether I used the -n option or not.

I have used an "exit 0" at the end of the command sequence executing remotely and tried a "return 0" neither of which should make a blind bit of difference but I'm at the grasping at straws stage. I also added an "exit 0" at the end of the final script executed remotely. None of these ploys made a blind bit of difference.

I have successfully executed that sequence of commands/scripts in a loop having already interactively remsh'd to one particular machine (that is it loops over the sequence several times but only on one machine, there is no remsh). This last experiment proves, I think, that it is some interaction between remsh and the remote sequence (or final script). The final script is not sufficient to cause the hang.

I have also started the original looping script from a Linux machine and used rsh instead of remsh and it still hangs.

Does anybody have similar experience to relate or, better, a solution to this phenomenon?

Thanks in advance
Ris

==========================================
toff.jpg
I phoned the local ramblers club today, and this bloke just went on and on.
 
Are by chance remsh AND the loop reading the same standard input ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
No, I haven't redirected stdin for the loop. Here is the script:
Code:
SS_LIST=${SS_LIST:-'
 lnx6:8600
 lnx6:8650
 lnx6:8700
'}

for SERVER in ${SS_LIST}
do
  M=$( print ${SERVER} | cut -d: -f1 )
  S=$(  print ${SERVER} | cut -d: -f2 )
  LL=${SERVER_DIR}/${M}/${S}/logs
  U=$( ls -l ${LL}/access_log | awk '{print $3}' )
  CMD=". /etc/profile                 ;\
. \${HOME}/.profile > /dev/null 2>&1  ;\
. \${HOME}/.kshrc                     ;\
export NXAOVERRIDE=LOCAL              ;\
\${HOME}/cadbin/stop_sync_server ${S} ;\
ps -Hfu ${U}                          ;\
\${HOME}/cadbin/start_sync_server ${S};\
return 0"

  remsh ${M} -n -l ${U} ${CMD}
  if (( $? == 0 ))
  then
    print "Logged on to ${M} as ${U} successfully"
  else
    print "Log on to ${M} as ${U} failed"
  fi
done

==========================================
toff.jpg
I phoned the local ramblers club today, and this bloke just went on and on.
 
My bet is, the command start_sync_server is either not returning to shell prompt, or it is not releasing stdin/stdout/stderr.

try nohupping the last command

Code:
nohup \${HOME}/cadbin/start_sync_server ${S} >/dev/null 2>&1 </dev/null & ;\



HTH,

p5wizard
 
Thx P5

I didn't want to run that last script in the background because I want to know when the script actually finishes. (Then I'll be able to test that the server is up by checking for stored process ids and so on.)

First I just added "< /dev/null" although this should have been done by the "-n" option on remsh. I started with this because I didn't want to throw away the output. It still hung.

Then I added "> /dev/nul 2>&1" and it worked cycling through three machines.

Then I took out 2>&1 and it hung again.

I ended up with
Code:
START_LOG=/tmp/sync_start_log.\$$     ;\
\${HOME}/cadbin/start_sync_server ${S} > \${START_LOG} 2>&1 < /dev/null;\
cat \${START_LOG}; rm \${START_LOG}   ;\

which works and gives me all the output I would have had before.

I still don't understand what's happening but then what's new, eh?

Ris

==========================================
toff.jpg
I phoned the local ramblers club today, and this bloke just went on and on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top