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

Rob Wolfe rw at smsnet.pl
Sun Nov 11 15:25:55 EST 2007


Michael  George Lerner <mglerner at gmail.com> writes:

> 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




More information about the Python-list mailing list