Reputation: 6989
I have following bash script:
export MYCONFIG_CONFIG=TEST
/home/bmwant/projects/test/venv/bin/python3 /home/bmwant/projects/test/script.py
My python script needs environment variable which I have set, but running this script as
bash run_python.sh
shows an error
/home/bmwant/projects/test/venv/bin/python3: can't open file 'home/bmwant/projects/tes': [Errno 2] No such file or directory
What is wrong? I have set script as executable with chmod u+x run_python.sh
Upvotes: 0
Views: 428
Reputation: 373
Have made script.py
executable?
chmod u+x /home/bmwant/projects/test/script.py
Try this script:
#!/bin/bash
export MYCONFIG_CONFIG=TEST
pushd /home/bmwant/projects/test/venv/bin/
./python3 /home/bmwant/projects/test/script.py
popd
You can run it via:
./run_python.sh
Upvotes: 1
Reputation: 6989
So, the problem was in file format. I have created it in Windows and then copy via FileZilla to remote server where I was trying to run it. So just run
apt-get install dos2unix
dos2unix run_python.sh
bash run_python.sh
and all will work well. Thanks @Horst for the hint.
Upvotes: 0