James Lam
James Lam

Reputation: 1269

Getting Location of Command in Popen

I am currently debugging a cmd run with Popen.

It looks like:

cmd = ['test', 'arg1', 'arg2']
Popen(cmd)

test is a python script and I have multiple on my computer. How do I tell which test is getting picked up when I call Popen()?

Upvotes: 1

Views: 35

Answers (1)

Joe Young
Joe Young

Reputation: 5895

If you're on Linux, try doing a Popen() or subprocess.check_output() on the which command, passing in test as an argument.

For example:

>>> import subprocess
>>> subprocess.check_output(["which", "test"])
b'/Users/joeyoung/.virtualenvs/myproject/bin/test\n'

Upvotes: 2

Related Questions