3

I have a problem...

import sys
import subprocess
subprocess.call(['traceroute -I www.yahoo.com'])

and I had try

import sys
import subprocess    
subprocess.call(['/usr/sbin/traceroute -I www.yahoo.com'])

why I am recieving the following error message: "OSError: [Errno 2] No such file or directory". Can anyone help...thanks!

dong
  • 43
  • 1
  • 5

2 Answers2

2

I hate to answer without knowing the much about the underlying reasons, but I've run into this before with subprocess. The call arguments list really wants a list -- I assume it is looking for an executable with spaces in the name, exactly matching what you enter. Try this instead:

import subprocess
subprocess.call(['traceroute', 'www.yahoo.com'])
Collin Green
  • 2,146
  • 14
  • 12
1
import sys
import subprocess
subprocess.call('traceroute -I www.yahoo.com',shell=True)

You can simply do this with shell=True option.

vks
  • 67,027
  • 10
  • 91
  • 124