Executing command remotely with ssh, and PATH
clanlaw at googlemail.com
Thu Aug 9 14:57:24 UTC 2012
On 9 August 2012 14:59, Karl Auer <kauer at biplane.com.au> wrote:
> On Thu, 2012-08-09 at 14:42 +0100, Colin Law wrote:
>> ssh remote_server "PATH=/some/path:$PATH; echo $PATH"
>> Can anyone put me straight?
> The variable is being expanded in the command, before the command is
> being sent to the remote server. You need to escape any dollar signs
> that are needed at the other end,
> Here is a sequence showing the effect
> kauer at karl:~$ unset FRED
> kauer at karl:~$ echo $FRED
> kauer at karl:~$ ssh localhost "FRED=blah ; echo $FRED"
> kauer at karl:~$ ssh localhost "FRED=blah ; echo \$FRED"
Yes of course, I guessed I was doing something stupid. Thanks Karl
and Tony. In fact I think I can just use single quotes instead of
double to stop the interpolation.
More information about the ubuntu-users