Want to run .auto.bash command in the script. Is there a way i can get this done?
#!/bin/bash _servers="/tmp/servers.txt" _out="/tmp/output.$$" _ssh=/usr/bin/ssh set -x for server in $_servers do $_ssh $s ./net/ussdp137/opt/EHS/scripts/auto.bash >>$_out done
I see no value in writing that, or most things, as a one-liner. It won't even work on the same line as the hashbang.
You don't define the variable 's' anywhere, either.
You don't read variables from a file that way, either.
You also don't need to open out.txt twelve times to write to it.
I can only guess that you mean to run the code on the remote side of the ssh call. Sure, you can do that. Redirect it into stdin and it will read it on stdin. Run 'exec bash' to get the shell you want running the way you want.
#!/bin/bash
while read -r S
do
ssh "$s" exec /bin/bash < ./net/ussdp137/opt/EHS/scripts/auto.bash
done < /tmp/servers.txt > /tmp/out.txt
#!/bin/bash
set -x
for host in `cat /tmp/servers.txt`; do
ssh -t $host "sudo su - -c /net/ServerX/opt/EHS/scripts/auto.bash"
done
what if i want to edit the script and check to see if this CA folder has been unlink or link example:
lrwxrwxrwx 1 root root 12 Oct 19 2011 CA -> /opt/autosys