jp129096
jp129096

Reputation: 3

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' as well as r'\; neww'

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

Upvotes: 0

Views: 355

Answers (1)

user11274868
user11274868

Reputation:

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)
>>>

Upvotes: 1

Related Questions