1

I have the following static method in Python.

import subprocess   

class ProcessUtility:

    @staticmethod
    def execute_command(url):
        process = None
        process = subprocess.check_output(["phantomas " + url  + " --har=test.har"])
        return process

It command basically writes the output to test.har file. I have created the test.har file in the same directory as that of the script and given it read,write and execute permissions.

Upon executing I get the error.

OSError: [Errno 2] No such file or directory

Any ideas why I keep getting this.

1
  • +1 for introducing me to subprocerss.check_output(). It's been so long since I've had to check the docs for subprocess that I'd never noticed the new addition for 2.7. Commented Nov 7, 2014 at 6:29

1 Answer 1

2

Most subprocess functions take a list of arguments as opposed to a string, if shell=False (the default). Try

process = subprocess.check_output(['phantomas', url, '--har=test.har'])
Sign up to request clarification or add additional context in comments.

1 Comment

Note shell=True can lead to unexpected behaviour. Be sure to check the docs for what it implies (essentially, arguments are interpreted as going to the shell, rather than the program).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.