Visit Our UNIX and Linux User Community


[Solved] Unable to call a python script from bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Unable to call a python script from bash
# 1  
Old 02-14-2013
[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:
Code:
#!/bin/bash

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

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

Please help me on this.

Last edited by Scrutinizer; 02-14-2013 at 06:17 PM.. Reason: code tags
# 2  
Old 02-14-2013
Does /opt/web/http.py exist?
# 3  
Old 02-14-2013
Yes it is exists.
# 4  
Old 02-14-2013
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?
This User Gave Thanks to DGPickett For This Post:
# 5  
Old 02-14-2013
What does
Code:
 ls -l /opt/web/http.py

give?
# 6  
Old 02-14-2013
My bet would be on /opt/web/http.py being a broken symbolic link.
# 7  
Old 02-15-2013
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.

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to print python array in shell script loop.

I am unable to loop print a python string array in my unix shell script: ~/readarr.sh '{{ myarr }}' more readarr.sh echo "Parameter 1:"$1 MYARRAY= $1 IFS= MYARRAY=`python <<< "print ' '.join($MYARRAY)"` for a in "$MYARRAY"; do echo "Printing Array: $a" done Can you... (10 Replies)
Discussion started by: mohtashims
10 Replies

2. Shell Programming and Scripting

How to use scl enable python command call with in bash shell script?

I have a bash shell script, within it i am using the below two commands . its failing right on scl enable command itself. if i run it by itself without a shell, it works fine. by default it is using pythin version 2.6 something. i want to use 3.4 version for that reason with in the shell... (3 Replies)
Discussion started by: cplusplus1
3 Replies

3. Shell Programming and Scripting

Beginner here, how to call a bash-script from python properly?

Hi everyone, i have the following script.sh: foo='lsusb | grep Webcam | cut -c16-18' sudo /home/user/public/usbreset /dev/bus/usb/001/$foo when i try to call this script from python using subprocess.call("script.sh", shell=True) it seems that only 'sudo /home/user/public/usbreset' is being... (6 Replies)
Discussion started by: hilfemir
6 Replies

4. UNIX for Advanced & Expert Users

Calling expect from shell script which inturn call python

Hi Team, I have to execute a task from my local machine, where i keep my .expect,.sh, .bash and .python scripts .Task are coded in the script and has to be executed at remote machine. for that i used following task ..... SCRIPT 1: cat shell_check.sh read value if then expect... (3 Replies)
Discussion started by: Sivarajan N
3 Replies

5. Shell Programming and Scripting

[Solved] Unable to mailx new $pid for a script restart

Ill try to make this brief: I am trying to get the script below to run another script defined as BATNAM. The script runs fine, does what i designed it to do, however... I would like it to mailx the NEW $pid that was restarted. This script is supposed to go in crontab as root, and run by... (8 Replies)
Discussion started by: olyanderson
8 Replies

6. UNIX for Advanced & Expert Users

Unable to call a script from another script in cshell

Hi, I am unable to call one script from another script in c shell on windows SUA environment. Please find below code , File1 āTmp.csh: #!/bin/csh setenv PATH "${PATH}:.:$TOP/bin:$TOP/RMBIN/bin:$GP_SUA/:$INTERIX_ROOT" echo "hi1" . /tmp1.csh File2ātmp1.csh ... (6 Replies)
Discussion started by: gthangav
6 Replies

7. Shell Programming and Scripting

Python call to bash script returns empty string

Hi all, I need help figuring out why my script won't work when envoked from web interface. First off, I'm fairly new to Linux and Shell scripting so, my apologies for being ignorant! So I have a python script that I envoke through a web interface. This script envokes my shell script and... (8 Replies)
Discussion started by: arod291
8 Replies

8. Shell Programming and Scripting

[solved] using backticks to call bash from perl

Hi all, Here is my code: my $x = `bash -c \" ls -l filename | awk '{print \$5}'\"`; print "$x\n"; This will run the first part of the bash script but not the awk command. It therefore gives output of: -rw-r--r-- 1 root root 13619200 2012-04-25 08:16 filename I am actually trying to... (0 Replies)
Discussion started by: free2rhyme2k
0 Replies

9. HP-UX

[Solved] Not able to call a script from another programatically

Hi, I need to call a shell script from another. Let me explain you with an example. a1.sh and b1.sh are two scripts. a1.sh calls b1.sh internally. If i run a1.sh manually, it internally calls b1.sh but the problem is There is a process that calls this a1.sh at regular intervals,... (1 Reply)
Discussion started by: hadarapu
1 Replies

10. Shell Programming and Scripting

Unable to call executable from script

Now I am using the HP-UX11.11 version. The scripts are runninh in KSH shell. While I wan to call one executable of any Pro*C file, I have got the following error, however the executable is running fine directly. testpri Started at 10.05.200923:40 /usr/lib/dld.sl: Bad magic number for... (0 Replies)
Discussion started by: priyankak
0 Replies

Featured Tech Videos