473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Trouble with subprocess.call(...) and zsh script (OSError: [Errno 8] Exec format error)

Hi,

(Python 2.5, OS X 10.4.10)
I have a program called pdb2pqr on my system. It is installed so that
"pdb2pqr" is in my path and looks like:

#\!/bin/zsh -f
/sw/share/pdb2pqr/pdb2pqr.py "$@"

When I call it via this script:

#!/usr/bin/env python
import subprocess
import tempfile
args = ('/sw/bin/pdb2pqr','--help')
output_file = tempfile.TemporaryFile(mode="w+")
print "Running",args
retcode =
subprocess.call(args,stdout=output_file.fileno(),s tderr=subprocess.STDOUT)
output_file.close()

I get this error:

localhost~/tmp$ ./x.py
Running ('/sw/bin/pdb2pqr', '--help')
Traceback (most recent call last):
File "./x.py", line 9, in <module>
retcode =
subprocess.call(args,stdout=output_file.fileno(),s tderr=subprocess.STDOUT)
File "/sw/lib/python2.5/subprocess.py", line 443, in call
return Popen(*popenargs, **kwargs).wait()
File "/sw/lib/python2.5/subprocess.py", line 593, in __init__
errread, errwrite)
File "/sw/lib/python2.5/subprocess.py", line 1051, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

But when I change it to directly call the script that the zsh script
calls like this:

args = ('/sw/share/pdb2pqr/pdb2pqr.py','--help')

everything works:

localhost~/tmp$ ./x.py
Running ('/sw/share/pdb2pqr/pdb2pqr.py', '--help')

This is with 2.5 on OS X 10.4.10. I'm happy to provide whatever
additional information might be useful.

Thanks,

-michael

Nov 11 '07 #1
2 7540
Michael George Lerner <mg******@gmail.comwrites:
Hi,

(Python 2.5, OS X 10.4.10)
I have a program called pdb2pqr on my system. It is installed so that
"pdb2pqr" is in my path and looks like:

#\!/bin/zsh -f
Are you sure that this shebang is correct?

I've tested that on bash and have similar error:

# t1.sh

#\!/bin/sh
echo "t1"
>>from subprocess import call
call(['./t1.sh'])
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/subprocess.py", line 413, in call
return Popen(*args, **kwargs).wait()
File "/usr/lib/python2.4/subprocess.py", line 543, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

But running that directly through the shell works:
>>call(['./t1.sh'], shell=True)
t1
0

However this script works fine also without `shell=True` option:

# t2.sh

#!/bin/sh
echo "t2"
>>call(['./t2.sh'])
t2
0
HTH,
Rob

Nov 11 '07 #2
On Nov 11, 3:25 pm, Rob Wolfe <r...@smsnet.plwrote:
Hi Rob,
Michael GeorgeLerner<mgler...@gmail.comwrites:
Hi,
(Python 2.5, OS X 10.4.10)
I have a program called pdb2pqr on my system. It is installed so that
"pdb2pqr" is in my path and looks like:
#\!/bin/zsh -f

Are you sure that this shebang is correct?
Well, it's correct in the sense that I have faithfully reproduced the
contents of the file. I didn't write it, though.

I don't know what the extra backslash is for. I suppose I'll contact
the authors and find out.

Any ideas how to make it work with the strange shebang syntax?

Thanks,

-michael
>
I've tested that on bash and have similar error:

# t1.sh

#\!/bin/sh
echo "t1"
>from subprocess import call
call(['./t1.sh'])

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.4/subprocess.py", line 413, in call
return Popen(*args, **kwargs).wait()
File "/usr/lib/python2.4/subprocess.py", line 543, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

But running that directly through the shell works:
>call(['./t1.sh'], shell=True)

t1
0

However this script works fine also without `shell=True` option:

# t2.sh

#!/bin/sh
echo "t2"
>call(['./t2.sh'])

t2
0

HTH,
Rob

Nov 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Piotr Wolski | last post by:
This message usually indicates there is a problem with the script itself. Often this indicates either that the #! line of the script is incorrect, or the script was uploaded in binary mode instead...
0
by: Matthew Fowler | last post by:
Hi there I have been porting python to the Etrax platform and everything seems to be working. However when I run the program in question I get: "problem with execution of xhpl on ...
11
by: Alec Wysoker | last post by:
Using Python 2.3.5 on Windows XP, I occasionally get OSError: Permission denied when calling os.remove(). This can occur with a file that is not used by any other process on the machine, and is...
0
by: Joram Agten | last post by:
Please put me in CC When running the following program I get frequent errors like this one Exception in thread Thread-4: Traceback (most recent call last): File...
10
by: k r fry | last post by:
Hi, I am new to this list and also programming with python. I have an error: oserror not a directory "katiescint.py" The piece of code causing the problem is: for subdir in...
0
by: robert | last post by:
e.g. open/os module functions (os.path.getmtime...) and win32api/win32file functions fail on long paths (>~255 chars) even the '\\?\' trick from...
1
by: Pradeep83 | last post by:
Hi All, Good Morning Here I am jotdowning my problem I am compiling a .c file in Free BSD 6.0 and exceuting there itself. and i have taken that...
7
by: timw.google | last post by:
Hi I want to write a python script that runs rsync on a given directory and host. I build the command line string, but when I try to run subprocess.call(cmd), or p=subprocess.Popen(cmd,...
0
by: siavashr | last post by:
Hi, I am new to python, and I am trying to do the following from my python code: echo 1 > /sys/devices/omapdss/display0/enabled I have tried to do this with the following functions: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.