I'm trying to run a local script remotely that I'm calling with some other code. The basic formate is
ssh -i ${PemKey} ${User}@${URL} 'bash -s' -- < ${Command}
I get the error line 24: ${Command}: ambiguous redirect
Command is a string with the name of the script I want to run and its arguments. If I change the script to just print the command as
echo "ssh -i ${PemKey} ${User}@${URL} 'bash -s' -- < ${Command}"
and then run the command myself it works just fine. I've tried putting the command in a temp variable and then call it that way, like:
TEMP="ssh -i ${PemKey} ${User}@${URL} 'bash -s' -- < ${Command}"
$TEMP
echo $TEMP
This results in No such file or directory. Again the echoed version of the command runs just fine at the command line.
Anyone know what I'm doing wrong here?
echo pwd | ssh localhost bash -sssh localhost bash -s <<< pwd. But this doesn't:ssh localhost bash -s < pwd."${Command}"(and all your other variables). Also, don't copy-paste parts of error messages: e.g.bash: : No such file or directorytells you way more than just the human readable text.