Closed as not planned
Closed as not planned
Description
Bug report
python file test.py:
import subprocess
import re
rc = subprocess.check_output("/home/user/test.sh")
print(rc)
bash file test.sh:
<newline here>
#!bin/bash
echo "Hello World"
When executing the subprocess.check_output fails to reckognize the bash script as executable due to the newline.
SyntaxError: invalid syntax
Traceback (most recent call last):
File "/home/user/test.py", line 5, in <module>
rc = subprocess.check_output('/home/user/test.sh')
File "/usr/lib64/python2.7/subprocess.py", line 216, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Your environment
Amazon Linux 2 - VM clean install
python 2.7.18
python 3.7.10
Is this expected behavior? or should there be any expected removing of preceding newlines?
Normal bash script execution works as intended even with newline in place.
Metadata
Metadata
Assignees
Labels
No labels