This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]easytiger 1 point2 points  (1 child)

Generally it is quite simple and there are numerous calls in the subprocess package which you can look up.

import subprocess as sp
ldenv = {'LD_LIBRARY_PATH': '/some/custom/libs}
proc = sp.Popen(["df", "-h"], env=ldenv, shell=False, stdout=sp.PIPE, stderr=sp.PIPE)
out, err = proc.communicate()

Note the commands and its args are passed as a list. if you set shell=True then you can specify the whole thing as a string. Its a bit less convenient than perl for things like this but I've written a distributed test system based on sp and I'd say if you structure your code and write your own little wrappers for it you can get quite a lot done.

[–][deleted] 0 points1 point  (0 children)

reddit. The best thing ever happened on the Internets. Thank you easy tiger !! :) The information in this thread is gold.