Some Linux users (including myself) have been unsuccessfully trying to execute a command via SSH, for example:
The problem seems to be that "mycommand" is in a directory that is not in the PATH. However, when they connect normally, they can see the directory in the PATH environment variable.
It seems that most of these users (again, including myself) update the PATH variable in the .bashrc file and, apparently, the .bashrc file is not executed when connected "non-interactively" via ssh.
After looking for a good while, many people suggested to check if the .bashrc was called by .profile or .bash_profile or something like that. Well... that did not solve my problem.
What, in fact, happened was that .bashrc was being called (or "sourced") by SSH, but the guys from the distro decided to add the following lines in it:
Basically, the test above only allows the execution of the rest of .bashrc if it is an interactive shell, thus it does not work for my needs. Why is it there? I have no idea... anyway... I just commented the test and it worked perfectly.
ssh user@host mycommand
The problem seems to be that "mycommand" is in a directory that is not in the PATH. However, when they connect normally, they can see the directory in the PATH environment variable.
It seems that most of these users (again, including myself) update the PATH variable in the .bashrc file and, apparently, the .bashrc file is not executed when connected "non-interactively" via ssh.
After looking for a good while, many people suggested to check if the .bashrc was called by .profile or .bash_profile or something like that. Well... that did not solve my problem.
What, in fact, happened was that .bashrc was being called (or "sourced") by SSH, but the guys from the distro decided to add the following lines in it:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
Basically, the test above only allows the execution of the rest of .bashrc if it is an interactive shell, thus it does not work for my needs. Why is it there? I have no idea... anyway... I just commented the test and it worked perfectly.