ssh - running remote command not exiting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh - running remote command not exiting
# 1  
Old 10-18-2012
ssh - running remote command not exiting

Hi,

i have a shellscript, where in i need to connect to different server start these three jobs and exit from the server and start the same three jobs on local server.

Code:
 
ssh user@remotehost 'bash -s' << EOF
${GETT_HOME}/bin/start1 &
sleep 10
${GETT_HOME}/bin/start2 &
sleep 10
${GETT_HOME}/bin/start3 &
echo "Started on secondary"
exit
EOF

script starts the jobs correctly on remote server however it never exits, ssh hungs at the end.

Appreciate your help
# 2  
Old 10-18-2012
ssh hungs because the invoked processes are still running.
You can use fork option:

Code:
ssh -f  user@remotehost "${GETT_HOME}/bin/start1 &  sleep 10; ${GETT_HOME}/bin/start2 & sleep 10; ${GETT_HOME}/bin/start3 & echo Started on secondary "

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

Running nohup command on remote server

I am having an issue in running a nohup command in a remote linux box from a linux box. Here are the details. Linux Machine 1: I have a script which starts a services and dumps the output into a log file. nohup sh weblogic.sh >> /home/log.out & I have placed the entire command in a... (2 Replies)
Discussion started by: accessbalaji
2 Replies

3. Shell Programming and Scripting

Ssh - running commands on remote server

Hi, I am trying to run commands on a list of servers that I can ssh to and just want to know if there is a 'cleaner' way of doing this. At the moment, I am doing as below. Is there a way that I can escape the double quote differently? If a use a single quote to enclose the commands that I... (1 Reply)
Discussion started by: newbie_01
1 Replies

4. Shell Programming and Scripting

Running Commands on a Remote Linux Server over SSH

Hello, I'm trying to create a ksh script to ssh to a remote server, enter the password and a couple commands. For security reasons I have changed the login, password and ip in my example. #!/bin/ksh ssh -t -t username@12.5.5.3 << EOF password cd bin pwd EOF When I run it. It... (5 Replies)
Discussion started by: seekryts15
5 Replies

5. Shell Programming and Scripting

Remote command in variable using ssh

Hi, I've an issue in a shell script: I'm opening an ssh connection to a remote server, then I want to store the result of a ls command in a variable, but it doesn't work: the ls is done on the local machine. ssh user@server << EOF ls # works as expected (ls is done remotely) test=`ls` # the... (1 Reply)
Discussion started by: seloum57
1 Replies

6. Shell Programming and Scripting

ssh to remote command prompt

Hi all, Scenario - trying to run a batch job on a second machine. DIR=directory user=user server=server Here is what i have- ssh user@server 'sleep2; cd $DIR; <jobname>' I have got access to the correct directory, i checked with a pwd command previous. Problem is the job i... (1 Reply)
Discussion started by: Hopper_no1
1 Replies

7. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

8. Shell Programming and Scripting

Problem running ssh from remote server

So I have a script which performs some basic commands on another server via ssh. It works great, no issues at all. Let's call this "Script A" BUT, this working script is to be executed remotely from a different UNIX script on another server, also by ssh. Let's call this "Script B". When... (1 Reply)
Discussion started by: newerakb
1 Replies

9. Solaris

Running command on Remote server

Hi, I have username/password for a remote server. I would like to have list of filenames and their size in a particular directory of remote server. Now Problem is - I can not use rsh command as I can not modify rhost file of remote server. Thanks in advance. Sanjay (1 Reply)
Discussion started by: sanjay1979
1 Replies

10. Shell Programming and Scripting

Running ssh on a remote system?

I need to install ypbind and yp-tools on over two-hundred remote client machines based on their redhat version. I have a centralized server on which I created an ssh public key. I then transfered the ssh public key to the authorized_keys file on all the remote hosts; therefore, I can login without... (1 Reply)
Discussion started by: cstovall
1 Replies
Login or Register to Ask a Question