Newbie question:

I'm trying to run a command located in /usr/local/bin/, via a shell script over ssh. But bash keeps giving a 'command not found' error.

If I modify the script to specify the command's full file path, it works just fine.

Why is this?
$PATH includes /usr/local/bin/. Why can't bash find it?

@htimsxela When you run something non-interactively via ssh I suspect that there is no login shell and .bash_profile wasn't executed. However, if your shell script is bash the session script .bashrc on the remote machine should be executed. Did you set your PATH variable there?


@FreePietje @waxwing
echo $PATH in script was a simple debug, and setting the variable in .bashrc was the fix. Exporting within the script itself could be a good fix in some cases too. Thank you all for your help!

Sign in to participate in the conversation
Bitcoin Mastodon

Bitcoin Maston Instance