import subprocess
subprocess.call(" python script2.py 1", shell=True)
This code does not work. It tells me permission is denied on python. Any fixes?
import subprocess
subprocess.call(" python script2.py 1", shell=True)
This code does not work. It tells me permission is denied on python. Any fixes?
I don't know if you are doing this in bash terminal but if you are you must give yourself rights to the .py file. So type this
chmod +x script2.py
Then the terminal will give you permission to it
Suggestions For Using Subprocess.call()
When shell=True is dangerous?
If we execute shell commands that might include unsanitized input from an untrusted source, it will make a program vulnerable to shell injection, a serious security flaw which can result in arbitrary command execution. For this reason, the use of shell=True is strongly discouraged in cases where the command string is constructed from external input
Reference : When to use Shell=True for Python subprocess module
import subprocess
subprocess.call(" python script2.py 1", shell=True)
Try avoid shell=True in subprocess. Instead use
import subprocess
subprocess.call(['python','script2.py','1'])
Pass every thing as a list , avoid shell=True
import subprocess
subprocess.call('python script2.py 1'.split())
'python script2.py 1'.split() will create a list like ['python','script2.py', '1']
Addressing Permission Issue
Add execution permission to your script.
chmod +x script2.py