I am looking to run multiple remote commands from one COZBATCH step.
In the first example, the job step ends after processing one saf-ssh-agent command. Is there additional setup I need? Thanks.
This doesn't work
saf-ssh-agent -c KEYRING ssh user@$i "cmd"
saf-ssh-agent -c KEYRING ssh user@$i "cmd"
This works
for i in server1 server2
do
echo $i
saf-ssh-agent -c KEYRING ssh user@$i "cmd"
done
Running multiple saf-ssh-agent commands from one STDIN
COZBATCH spawns a child process to run /bin/sh and pipes it the script to be executed from //STDIN.
When you run a command that attempts to read from stdin/fd0 (ssh in your case), the pipe gets clipped and the streaming of the script stops.
To avoid this, you can either have COZBATCH get its script from a file rather than using STDIN, or just make sure that the commands you run don't try to read from stdin. The following change to your original example should fix the problem.
When you run a command that attempts to read from stdin/fd0 (ssh in your case), the pipe gets clipped and the streaming of the script stops.
To avoid this, you can either have COZBATCH get its script from a file rather than using STDIN, or just make sure that the commands you run don't try to read from stdin. The following change to your original example should fix the problem.
Code: Select all
saf-ssh-agent -c KEYRING ssh user@$i "cmd" < /dev/null
saf-ssh-agent -c KEYRING ssh user@$i "cmd" < /dev/null
Yes I can
The shell has to read the entire for construct before issuing any of the embedded commands. By the time the first ssh command is run, the loop is set up. If you tried to put anything after the loop, it would fail to run.
If you put the < /dev/null stdin redirect on the ssh command, it prevents him from competing for the stdin stream. You should put it on even inside the loop.
The shell has to read the entire for construct before issuing any of the embedded commands. By the time the first ssh command is run, the loop is set up. If you tried to put anything after the loop, it would fail to run.
If you put the < /dev/null stdin redirect on the ssh command, it prevents him from competing for the stdin stream. You should put it on even inside the loop.