1

Hi I am new to linux and trying to get a program to work.

I followed the following instructions:

Edit your ~/.bashrc file to set up the environment for the caffe U-Net software:

export PATH=$PATH:/home/unetuser/u-net/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/unetuser/u-net/lib 

Now the expected bahviour is that when i run caffe I get the expected output, and indeed that works as expected.

However when i try:

ssh localhost caffe
bash: caffe: command not found

Why can i not use the caffe command with ssh?

according to this answer using ssh localhost <command> loads the ~./bashrc profile which has the correct command path.

7
  • 1
    "the expected bahviour is that when i run caffe I get the expected output". Ignoring ssh for a moment, does this step work? Jun 12, 2020 at 11:53
  • yes it works as expected. I can also connect to ssh localhost and then run caffe. It is the full command ssh localhost caffe that returns the :bash: caffe: command not found Jun 12, 2020 at 12:06
  • Hi I have carefully read the answer. Accordingly it specifies that when a ssh command is run then It will not start a login shell, therefore ~/.bashrc is what will be read. As my commands are added to the ~/.bashrc file I expect them to be read when executing ssh localhost 'command'. However the command is not found despite being in the ./bashrc Jun 12, 2020 at 12:25
  • 1
    Please try ssh localhost 'getent passwd $USER' | awk -F: '{print $1,$7}' (for localhost as per your question). First field should be your expected username. Is the second field /bin/bash - and if not, what is it? Jun 12, 2020 at 12:34
  • 1
    betaglutamate /bin/bash yes works as expected Jun 12, 2020 at 12:42

1 Answer 1

1

When running a remote command like this ssh does not run the command with a login shell (that is, it does not source ~/.bashrc. If you'd like to force it to do so, you can run the command with bash -l -c :

ssh localhost bash -l -c 'caffe'
4
  • Yes it does. Create a single line .bashrc with echo This is .bashrc. Then try ssh thathost id. You'll see the message printed before the output of id Jun 12, 2020 at 15:35
  • so this answer works. I am not sure if this fixes the problem as I believe the program calls ssh localhost caffe. I will mark this as correct if it fixes the issue. Jun 12, 2020 at 15:57
  • @roaima, I tried your experiment and did not get the message printed out of .bashrc Maybe the behavior changes across versions? I'm using OpenSSH 7.4.
    – John Moon
    Jun 12, 2020 at 15:59
  • Ok so i do not see the message echo This is .bashrc when in ~/.bashrc I have marked this as the correct answer because it explains what I am seeing and is producing the expected behaviour. I may open another question if I am having issues with the program Jun 12, 2020 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .