1
votes

I did this:

ssh me@remote which hg

returned nothing presumably because it couldn't find hg.

So then I did this:

ssh me@remote echo $PATH

which returned this long mess: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/opt/bin

Then I did this:

ssh me@remote
<after getting logged in to the remote computer>
which hg
/opt/bin/hg

Why would the server be able to find the hg binary in one instance, but not in both? What do you have to do to fix it so the

ssh me@remote which hg 

works?

1
Try ssh me@remote echo $(which hg), although I don't know why it wouldn't work the other way. And which should complain if it doesn't find the program, so it's probably not a problem with PATH not being set. - ooga
I have always seen which either print the path to the program with the name points to (i.e. which ls would print /bin/ls) and if there is no such program, it prints nothing, but it returns 1. - zelinka
I don't have your vast experience, but on my system it complains rather bitterly. Did you try my suggestion? - ooga
I tried that suggestion but it printed the location of the hg binary on my local computer. - zelinka
Perhaps ssh me@remove bash -c "which hg" (or whichever shell you want). - ooga

1 Answers

0
votes

This should work (as ooga mentioned).

ssh me@remote "which hg || whereis hg"