简体   繁体   中英

Python syntax to open gnome-terminal and execute multiple commands

I am developing a Auto install x2go script in Python (for ubuntu/linux especially) i'v come to where i got an gnome terminal open with the command os.system("gnome-terminal -e 'bash -c \\"sudo apt-get update -y ; exec bash\\"'")

it works fine, but now comes my problem. i have to execute more than the one command in the same terminal window, but i cant figure out how to split or define two commands in the same line. i have tried --tab -e [command] but it doesn't seem to work with my previous syntax os.system("gnome-terminal -e 'bash -c \\"sudo add-apt-repository ppa:x2go/ppa --tab -e sudo apt-get update ; exec bash\\"'")

i would be glad if i could get some help with this :)

Best Regards

For anyone stumbling on this page from Google, the answer was resolved in comments.

Simply chain the commands like you normally would in bash

os.system("gnome-terminal -e 'bash -c \"sudo add-apt-repository ppa:x2go/ppa && sudo apt-get update ; exec bash\"'")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM