I am trying to get the contents of a symlink remotely, but I am having a hard time understanding why is not working.
I tried following the example on this post. but is not working for me. This is what I am trying to do.
SYMB_LINK=`ssh files@files_server.com 'readlink $PATH_LINK'`
SYMB_LINK=`ssh firstname.lastname@example.org_server.com 'readlink path/to/file'`
First of all, don't use
~ because that will probably be expanded by your shell using the user settings of the user on your local machine rather than the remote machine.
Secondly, you should not use the
$ character on the left-hand side when assigning to a shell variable.
Taking all this advice and combining it together, we get:
LINK_PATH=/home/david/link LINK_TARGET=$(ssh example.com "readlink $LINK_PATH")