Posted By

fnurl on 04/26/09


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


call os command from python

 / Published in: Python


The advantage of subprocess vs system is that it is more flexible (you can get the stdout, stderr, the "real" status code, better error handling, etc...). I think os.system is deprecated, too, or will be:

For quick/dirty/one time scripts, os.system is enough, though.

  1. from subprocess import call
  2. call(["ls", "-l"])

Report this snippet  

You need to login to post a comment.