ssh can't back from remote host during script execution


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh can't back from remote host during script execution
# 1  
Old 01-17-2010
ssh can't back from remote host during script execution

Hi all

I wrote a script to execute a script on several remote hosts, but somehow during the execution of the local script, ssh can't come back from the remote host, so that causes my local script hanging... I use the below command to do the job in the local script, any idea?

Code:
ssh <user>@<remote host> "<path name>/<script name>" >> WorkLog.log

I think it may have some relation with the tunnel not closed, but I don't know how to solve that...
# 2  
Old 01-17-2010
Try to put the script which you want to use in some remote host under the below syntax :

"connection string" !<<EOF

your code

!

This helps the remote host to identify the part of the script its executing remotely.
! you can keep anything but consistency nneds to be maintaned for both the places.

Thanks.
# 3  
Old 01-18-2010
Thanks navojit, will try your method.
# 4  
Old 01-18-2010
May be the script is taking too long to execute or ssh may be the problem, try using ssh -vv to debug if above technique does not work.
# 5  
Old 01-18-2010
Hi dinjo, the script is very short actually, by monitoring the log I found the remote script can finish, but can't come back from remote machine.
# 6  
Old 01-18-2010
Did you tried running the script from command line.
# 7  
Old 01-18-2010
Hi dinjo, that script on that remote host execute a series of other scripts. I can briefly tell you what the remote script do,it run a stop script->show status-> run a start script -> show status. After the second show status done, it will just be hanging there.

If I ssh to that host and run scripts, they runs ok
Code:
ssh hostname
cd <path name>
hostname>./stop script
hostname>./show status
hostname>./start script
hostname>./show status

If I remote execute in my local script
Code:
ssh <user>@<remote host> "<path name>/<stop script>" >> WorkLog.log
ssh <user>@<remote host> "<path name>/<show status>" >> WorkLog.log
ssh <user>@<remote host> "<path name>/<start script>" >> WorkLog.log
ssh <user>@<remote host> "<path name>/<show status>" >> WorkLog.log

every thing I need will be in log, that means they are executed, but I need to use Ctrl+C to get my prompt back on local machine.

Last edited by bzylg; 01-18-2010 at 02:21 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

SSH to remote host using SOCK5 proxy

I am trying to connect to a remote host C from my node host A. HostA <====> HostB <====> HostC A tunnel has already been formed using SOCKS5 between HostA and HostC. Now I want to SSH from A to C. The SOCKS5 IP us 142.133.132.161 and port 1082. The command I am using is : ssh -L... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

2. Shell Programming and Scripting

Remote script over ssh execution issues.

If I execute below code I am able to get string from column8 and column10 about a process. serverA1$> ps -ef | grep rotate | grep 'config' | awk '{print $8" "$10}' /<Oracle_home>/ohs/bin/odl_rotatelogs -h:/<app_Home>/config/OHS/ohs1/component_events.xml_ohs1... (12 Replies)
Discussion started by: kchinnam
12 Replies

3. Shell Programming and Scripting

Execute command on remote host via ssh

How should i make the following code working #!/bin/bash INPUTFILE="test.txt" while read STRING; do IP=`host -t A $STRING | awk '{print $NF}'` HOSTNAME=`ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no $IP "hostname"` echo $HOSTNAME > out.txt done < $INPUTFILE At this moment while... (3 Replies)
Discussion started by: urello
3 Replies

4. Shell Programming and Scripting

Pause processes in remote host and resume execution in another remote host

Hi, Given addresses of 2 remote machines, using a shell script is it possible to get the state of running processes in "src" stop all the processes in "src" exit out of "src" ssh into "dest" resume the state of executing processes captured in step 1 in "dest" Assumption: "src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies

5. UNIX for Advanced & Expert Users

Help! How to find the local host after few ssh hops to remote host???

I do a ssh to remote host(A1) from local host(L1). I then ssh to another remote(A2) from A1. When I do a who -m from A2, I see the "connected from" as "A1". => who -m userid pts/2 2010-03-27 08:47 (A1) I want to identify who is the local host who initiated the connection to... (3 Replies)
Discussion started by: gomes1333
3 Replies

6. Solaris

unable to ssh to remote host

server is ok, I can login on console. however, when I use SSH teachia, there is no repsond. i have check ps-ef | grep ssh, it shows ok. restart ssh too. still not working. Anything else I need to check? # ps -ef | grep ssh root 24706 1 0 Jun 12 ? 0:00... (7 Replies)
Discussion started by: uuontario
7 Replies

7. Shell Programming and Scripting

ssh to remote host and execute command

Hi, could anyone please tell me how to ssh to remote host foo and execute command on it and print the result on local host? Thanks, Paresh (1 Reply)
Discussion started by: masaniparesh
1 Replies

8. Shell Programming and Scripting

ssh to a remote host

i want a script with expect or perl or shell which will do ssh to remote host...it will take commandline argument and run the script in remote host....... i.e that will be like ./ssh.exp remoteip username passwd /tmp.kk.sh can someone help me on this? (1 Reply)
Discussion started by: Aditya.Gurgaon
1 Replies

9. UNIX for Dummies Questions & Answers

Is it possible for a server to be both a remote and client SSH host?

Hi, Not sure if this is possible, I have a server (SERVER1) that is currently set up as a remote SSH host. My client SSH host (SERVER2) is connecting to SERVER1 to scp a file with no password. I now have a need to set up a third server (SERVER3) as a remote SSH host and I need SERVER1 as a... (4 Replies)
Discussion started by: tatchel
4 Replies

10. Shell Programming and Scripting

check ssh connection to remote host

I am using KSH and I need to check whether the remote host has been configured with ssh public key. Is there any way we can check inside a script? (6 Replies)
Discussion started by: praveenbvarrier
6 Replies
Login or Register to Ask a Question