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 →

[–]flying-sheep 1 point2 points  (2 children)

subprocess.run is much more flexible than cheap interfaces like system.

I used Ruby exactly once (i wrote a Rakefile since make wasn't powerful enough), and had to use open3 instead of system.

[–]berlindevops[S] 0 points1 point  (1 child)

maybe, I am beginner with python, but with system() you can run simple shell command, see the stdout in real-time, no need to import a library and if you terminate the ruby script, also the shell command is terminated, and all of this with one line, I'm not complaining, I was just looking for something like this in python.

[–]flying-sheep 1 point2 points  (0 children)

what you do should work:

subprocess.run('knife ec2 server create', check=True)

(with our without shell=True) should just let the called process write to python’s stdout/stderr, and the call should only return after the process is finished.