samnyc
July 26, 2016, 12:41pm
1
Hi,
I got most of the script working, last part which does the ssh to remote and execute the command not working.
for SSH in ${HostList}; do
echo ${SSH}
echo ""
SSH2SEND=ssh user@${SSH} curl -v $URL
echo $SSH2SEND
done
error message I am getting user@10.xx.xx.xx: command not found
RudiC
July 26, 2016, 12:44pm
2
There's obviously a double quote missing.
samnyc
July 26, 2016, 12:46pm
3
Thanks. I fix the double quote but now I get command not found.
Quote the string
SSH2SEND="ssh user@${SSH} curl -v $URL"
RudiC
July 26, 2016, 12:49pm
5
Please DON'T modify posts that have been referred to by others pulling the rug from under them!
You need to use "command substitution" like
SSH2SEND=$(ssh user@${SSH} curl -v $URL)
samnyc
July 26, 2016, 2:24pm
6
I added the quote back on. Now I don't get any error message but it doesn't do anything. it just prints this on the screen.
for SSH in ${HostList}; do
echo ${SSH}
echo ""
SSH2SEND="ssh user@${SSH} curl -v $URL"
echo $SSH2SEND
done
Here is the output...
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx
ssh user@10.xx.xx.xx curl -v test.com
10.xx.xx.xx
ssh user@10.xx.xx.xx curl -v test.com
---------- Post updated at 02:24 PM ---------- Previous update was at 01:37 PM ----------
I think i am close but not 100%. I updated the script. now I get SSH error message.
line 69: (ssh: command not found
(ssh user@10.xx.xx.xx curl -v test.com)