Reputation: 1821
I have a command in quotes:
ssh -i "/home/$USER/$KEY" "$USER"@"$WORKER1IP" "echo 'if [[ `uname -a` == Darwin* ]]; then' >> /home/$USER/tachyon-0.5.0/conf/tachyon-env.sh"
The "uname" part has to be written literally, not executed. I tried using "\" before the 'uname' part, but I don't know how to close it. Can someone help please?
Upvotes: 0
Views: 65
Reputation: 22428
This should work:
ssh -i "/home/$USER/$KEY" "$USER"@"$WORKER1IP" "echo 'if [[ \"\$(uname -a)\" == Darwin* ]]; then' >> /home/$USER/tachyon-0.5.0/conf/tachyon-env.sh"
and this too:
ssh -i "/home/$USER/$KEY" "$USER"@"$WORKER1IP" "echo 'if [[ \`uname -a\` == Darwin* ]]; then' >> /home/$USER/tachyon-0.5.0/conf/tachyon-env.sh"
Upvotes: 1
Reputation: 530990
Use a here document instead, which simplifies the nested quotes.
ssh -i "/home/$USER/$KEY" "$USER@$WORKER1IP" <<EOF
echo 'if [[ $(uname -a) == Darwin* ]]; then' >> "/home/$USER/tachyon-0.5.0/conf/tachyon-env.sh"
EOF
Upvotes: 1
Reputation: 785008
You can use $(...)
with escaped $
in BASH:
ssh -i "/home/$USER/$KEY" "$USER"@"$WORKER1IP" "echo 'if [[ \$(uname -a) == Darwin* ]]; then' >> /home/$USER/tachyon-0.5.0/conf/tachyon-env.sh"
Upvotes: 1