How can I launch a bash command with multiple args (for example "sudo apt update
") from a python script?
|
@milne's answer works, but I prefer to use
Please note that this doesn't invoke If you find yourself doing a lot of (different) command invocations from Python, you might want to look at plumbum. With that you can do the (IMO) more readable:
|
|||
|
It is possible you use the bash as a program, with the parameter -c for execute the commands: Example:
|
|||
|
The subprocess module is designed to do this:
If you would like the script to terminate if the command fails, you might consider using
|
|||||||||||||
|