Python: Calling CLI (command line) functions from code

This was a tricky one for me. I was trying to use wget to download a file but it wouldn't work properly!"wget --tries=3 --retry-connrefused")

Once I ran it...

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.6/", line 470, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.6/", line 623, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

What the hell? Everything is right!

Turns out I was missing a certain keyword in the call. Some functions require you to add in "shell = True"."wget --tries=3 --retry-connrefused", shell = True)


Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog