I'm trying to run a shell script as part of automated python but I got this error (in below):
Traceback (most recent call last):
File "def3.py", line 68, in <module>
shellscript = subprocess.Popen([sh_execute], stdin=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied:
I have tried with os.system() which gives permission denied errors
(I tried with #!/usr/bin/env python
and #!/usr/bin/python
but didn't work)
def get_directories(path):
directories = [x for x in os.listdir(path)] # 'directories' = x which is in the 'path'
directories = [(path + x) for x in directories] # now directories = x that x is x + path
return directories
_dir = get_directories(dest)
for i in range(len(_dir)):
sh_execute = _dir[i] + '/' + 'geo.sh'
#os.system('sh ' + sh_execute)
shellscript = subprocess.Popen([sh_execute], stdin=subprocess.PIPE)
shellscript.stdin.write("yes\n")
shellscript.stdin.close()
returncode = shellscript.wait()