I have to make ssh request for different nodes based on given IP.
different ssh commands are stored in node.txt as below
0.0.0.0 a ssh -t user@0.0.0.0 sudo -u node0 /path/script.sh
0.0.0.1 b ssh -t user@0.0.0.1 sudo -u node1 /path/script.sh
0.0.0.2 c ssh -t user@0.0.0.2 sudo -u node2 /path/script.sh
I try to grep the needed ssh command like this
comm=$(grep 0.0.0.2 node.txt | grep c | cut -f3)
when I run
status=$($comm)
the following error appears:
/path/script.sh not found
while if I hard coded the command in the script itself it work correctly,
comm='ssh -t user@0.0.0.2 sudo -u node2 /path/script.sh'
status=$($comm)
what could be the problem here?