Я пытаюсь запустить сценарий оболочки как часть автоматического Python, но я получил эту ошибку (ниже):
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:
Я пытался с os.system (), которая дает ошибки запрещенного разрешения(Я пытался с #!/usr/bin/env python
и #!/usr/bin/python
, но не работал)
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()