- edited description
"OSError: [Errno 8] Exec format error" raised when running a script with shell=False
Issue #24
invalid
$ cat test.sh
exit 1
In [1]: from sarge import run
In [2]: p = run('./test.sh')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-ada95d880d6b> in <module>()
----> 1 p = run('./test.sh')
/home/dmalinovsky/.virtualenvs/venv/lib/python3.3/site-packages/sarge/__init__.py in run(cmd, **kwargs)
1364 else:
1365 with Pipeline(cmd, **kwargs) as p:
-> 1366 p.run(input=input, async=async)
1367 return p
1368
/home/dmalinovsky/.virtualenvs/venv/lib/python3.3/site-packages/sarge/__init__.py in run(self, input, async)
995 self.commands = []
996 self.opened = []
--> 997 self.run_node(self.tree, input=input, async=async)
998 return self
999
/home/dmalinovsky/.virtualenvs/venv/lib/python3.3/site-packages/sarge/__init__.py in run_node(self, node, input, async, event)
1083 kind = node.kind
1084 method = 'run_%s_node' % kind
-> 1085 result = getattr(self, method)(node, input, async)
1086 if event:
1087 event.set()
/home/dmalinovsky/.virtualenvs/venv/lib/python3.3/site-packages/sarge/__init__.py in run_command_node(self, node, input, async)
1229 kwargs['stderr'] = self.stderr or stderr
1230 node.cmd = self.new_command(node.command, **kwargs)
-> 1231 node.cmd.run(input=input, async=async)
1232
1233 def get_status(self, node):
/home/dmalinovsky/.virtualenvs/venv/lib/python3.3/site-packages/sarge/__init__.py in run(self, input, async)
621 else:
622 self.kwargs['stdin'] = subprocess.PIPE
--> 623 self.process = p = Popen(self.args, **self.kwargs)
624 self.stdin = p.stdin
625 logger.debug('Popen: %s, %s -> %s', self, self.kwargs, p.__dict__)
/home/dmalinovsky/.pyenv/versions/3.3.4/lib/python3.3/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)
815 c2pread, c2pwrite,
816 errread, errwrite,
--> 817 restore_signals, start_new_session)
818 except:
819 # Cleanup if the child failed starting.
/home/dmalinovsky/.pyenv/versions/3.3.4/lib/python3.3/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1439 else:
1440 err_msg += ': ' + repr(orig_executable)
-> 1441 raise child_exception_type(errno_num, err_msg)
1442 raise child_exception_type(err_msg)
1443
OSError: [Errno 8] Exec format error
In [3]: p = run('./test.sh', shell=True)
In [4]: p.wait()
In [5]: p.returncode
Out[5]: 1
Comments (2)
-
reporter -
repo owner - changed status to invalid
This is how
subprocess
works, andsarge
is a wrapper oversubprocess
. This is not a bug: if you want to run a shell script withshell=False
, provide the path to the shell at the start of the command line. - Log in to comment