+ 2

Is it good to use the subprocess module or os module for linux command execution?

I always have a tendency to use Linux commands like subprocess('unane -a'.split()). Or is there another way, infact what is the better way or how should I go about?

5th Mar 2017, 10:47 AM
chiju
chiju - avatar
2 odpowiedzi
+ 12
I always use the os module. os.system("bash command in quotes") which runs the process on the main thread. Probably the best method is to make a shell script first and execute that from python, especially if you need to run a bunch of Bash commands. Also, from the shell script, you can modify $PATH without it changing in Python, letting you run different subprocesses concurrently, if you need to for whatever reason
6th Mar 2017, 12:23 AM
Aidan Haddon-Wright
Aidan Haddon-Wright - avatar
0
thanks Aidan
13th Mar 2017, 8:07 PM
chiju
chiju - avatar