Can't run a linux .sh script with python subprocess?
Question: I am trying:

    
    
    import subprocess
    subprocess.call(["file.sh"])
    

But I keep getting:

    
    
    Traceback (most recent call last):
      File "project.py", line 85, in <module>
        subprocess.call(["file.sh"])
      File "/usr/local/lib/python2.7/subprocess.py", line 522, in call
        return Popen(*popenargs, **kwargs).wait()
      File "/usr/local/lib/python2.7/subprocess.py", line 710, in __init__
        errread, errwrite)
      File "/usr/local/lib/python2.7/subprocess.py", line 1335, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory
    

However when I try and run the script from the shell `bash file.sh` it works.
So I'm confused as to why it doesn't work?

I am not committed to using subprocess so if there are other options please
let me know.


Answer: The `call` function of the `subprocess` package runs the command specified in
arg as a list of strings (to simplify).

To call your file you have put in your script:

    
    
    import subprocess
    subprocess.call(["sh", "file.sh"])
    

