简体   繁体   中英

executing a tmux command normally containing '\;' using subprocess.run

First of all, yes. I did read a few questions concerning this issue, and I do understand that escaping should be unnecessary (I even specified shell=False ).

my issue is that

subprocess.run(['tmux', '-n top', 'top', '; neww'])

causes a tmux session to open and immediately close

I am trying to achieve the same result as executing

tmux new -n top top \\; neww

in the shell.

I have also tried specifying shell=True and using '\\\\; neww' '\\\\; neww' as well as r'\\; neww' r'\\; neww'

it does not appear that anything is being written to stderr either.

Each argument needs to be individual:

>>> import subprocess
>>> subprocess.run(['tmux', 'new', '-d', '-n', 'top', 'top', ';', 'neww'])
CompletedProcess(args=['tmux', 'new', '-d', '-n', 'top', 'top', ';', 'neww'], returncode=0)
>>>

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