views:

71

answers:

1

I have a client and a host program (written in c) which I want to run from two different remote locations simultaneously. Since I have to do this some 50 times to gather data, I don't want to have to run them individually. On one side, I need to log in via ssh, start the script and tell it to write the output to a file. Then I need to log into another box via ssh and tell it to send the data, and then repeat the whole process another 49 times.

I figure what I need is to do is run the two commands from two separate windows.

How do I tell a single bash script to spawn two windows, input separate commands into each window and then come back to the parent window?

+2  A: 

Unless your client and host each need terminals, you should be able to background them, especially if your output is going to a file.

ssh user@machine1 host_prog args > output file &
ssh user@machine2 client_prog args &
Dennis Williamson
thanks. I just discovered this myself, but I also didn't know that you could start a command from the ssh line.
piggles
important thing to add: you might want to get the pid from the process so you can wait on it finishing. The pid is stored in $# after each process is spawned.
piggles