I'm trying to send a bash command over SSH using ssh -q $REMOTE -x "command"
.Because I have multiple bash commands, I'm using << EOF
.
The problem is that the readlink command returns me an empty string when I assign its result to a variable. When I call it directly, it's not.
Here is a simplified version of my code :
ssh -q $REMOTE -x << EOF LINK="/path/to/my/link" # the link points to /path/to/my/file readlink $LINK # outputs /path/to/my/file TEST=$(readlink -f "$LINK") echo $TEST # outputs an empty stringEOF
At that point I put the same code in a shell script on the remote machine and tried to call the shell script :
# local machinessh -q $REMOTE -x << EOF ./test-scriptEOF
# remote machine "test-script"LINK="/path/to/my/link" # the link points to /path/to/my/filereadlink $LINK # outputs /path/to/my/fileTEST=$(readlink -f "$LINK")echo $TEST # outputs /path/to/my/file
Suddently it's working, when I'm calling the remote script everything works fine, but why is it not working over ssh ?