Link to home
Start Free TrialLog in
Avatar of Los Angeles1
Los Angeles1

asked on

Linux, remote scripts with ssh (spawn a new script)

I got my remote script to work.  I appreciate everyone's help

I am using a putty app from Windows, and then I can use ssh to remotely start a script

and the output from the client program prints out on my putty screen and waits to print more messages (no keyboard is accepted, just print statements.

I am using this command to start the process

sshpass -p 'xxxx' ssh root@xxclnt2 /home/test

This is working successfully as I get something like:

sshpass -p 'xxxx' ssh root@xxclnt2 /home/test
output line 1
output line 2
output line 3 
...

Open in new window


I have a new issue

I want to do now is to run 10 of these ssh remote scripts from the same file

I do NOT want the out put to print on my screen.  I simply want it to run in the background without actually printing to a screen or device.  So I tried this

sshpass -p 'xxxx' ssh root@xxclnt2 /home/test > nul
sshpass -p 'xxxx' ssh root@xxclnt32 /home/test > nul

However, the script never actually gets to  the second line, since it is busy trying to perform the first one by putting the output of the command into nul

Is there any way to 'spawn' a command like this, so I can put multple lines such as this into a script

Thanks
Avatar of RaithZ
RaithZ
Flag of United States of America image

put them all on one line.. and put a semi-colon between them, and then put an & at the end of the command line.  This should cause the commands to all execute at once.

sshpass -p 'xxxx' ssh root@xxclnt2 /home/test > nul; sshpass -p 'xxxx' ssh root@xxclnt2 /home/test > nul &

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial