Issue
I have a shell script which transfers a file from my computer to an EC2 instance on AWS using scp. Once transferred, it executes the shell script on the EC2 instance using command execution over ssh. The command in the shell script that I am trying to run (among other commands) is:
pipenv install
When I run the parent shell script on my local machine, it transfers the file correctly, runs most of the transferred shell script correct, but generates an error at the pipenv command saying:
pipenv: command not found
If I ssh into the machine and execute the (now local) shell script with the pipenv command, it runs fine.
I cannot figure out what the difference is between running the shell script via ssh or running it locally, and why I get an error when run over ssh. Any advice and help would be greatly appreciated.
Solution
The difference is the PATH variable which defines the location of binaries in your system is not accessible if you run it without shell especially if it's defined under .bash_profile or /etc/profile
so either you set the PATH variable inside your shell script
for example
PATH=~/opt/bin:$PATH
or while you're under your bash try to find the full path of your binary by using
which pipenv
and in your script replace pipenv with full path
Answered By - AWS PS Answer Checked By - Gilberto Lyons (WPSolving Admin)