Executing command remotely with ssh, and PATH

C de-Avillez hggdh2 at ubuntu.com
Thu Aug 9 15:02:50 UTC 2012


On Thu, 9 Aug 2012 14:42:49 +0100
Colin Law <clanlaw at googlemail.com> wrote:

> There is apparently something I am not understanding about ssh or
> environment variables.  I can execute a command remotely using ssh,
> something like
> ssh remote_server "command_to_execute"
> and that works ok.  However in another case I need to add to the path
> before executing the command so I to test the concept I tried
> ssh remote_server "PATH=/some/path:$PATH; echo $PATH"
> but it just shows the original path.  If I login to the remote server
> and copy/paste the above command then it shows the extended path as
> expected.


(others already answered on the basic issue)

Depending on the shell you are running remotely, you may also have to
export the new variable setting, like:

PATH=/whatever; export PATH # bash syntax

..C..
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20120809/d4186e65/attachment.pgp>


More information about the ubuntu-users mailing list