+ 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?
2 Respostas
+ 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
0
thanks Aidan