[Solved] Unable to call a python script from bash

Hi,

I am trying to run a python script embedded in bash script. But is throwing me an error. Please help.

Script:

#!/bin/bash

nohup /usr/bin/python /opt/web/http.py &

Error:

/usr/bin/python: can't open file '/opt/web/http.py': [Errno 2] No such file or directory

Please help me on this.

Does /opt/web/http.py exist?

Yes it is exists.

It seems like a fair error. However, you are working too hard. Make /opt/web/http.py executable, make the first line "#!/usr/bin/python", put /opt/web in $PATH and just say "nohup http.py &" Make sure you are in a directory where you can create and write nohup.out.

If debugging mysteries, nothing beats running it all under strace/truss/tusc with lots of options -faelo /tmp/test/tr -rall -wall -xall or similar, so you can see all the calls and exactly where the error is. Sometimes the report is only half true. Something is missing, but what?

What does

 ls -l /opt/web/http.py

give?

My bet would be on /opt/web/http.py being a broken symbolic link.

Hi DGPickett,

Thanks for your help. Your solution worked. The file does not have executable permissions so python is not able to read the file.

I changed the permissions and restarted bash script. It's working. Thanks Buddy.