Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Connect to a remote server, attach to a tmux session, run a command #2282

Open
sla-te opened this issue Oct 13, 2023 · 0 comments

Comments

@sla-te
Copy link

sla-te commented Oct 13, 2023

Doing tmux send-keys ... does of course work but will require to use pipe-paneand results in only having a log file to tail the piped stdout/err from the tmux session..

If going:

from fabric import Connection
c = Connection('root@192.168.1.1')
c.run("tmux attach-session -t my_session", pty=True)
# i want to run commands inside the attached session now

Obviously it will block at c.run and provide interactive terminal to the tmux session on the server we connected to. Disabling pty will yield to the "not a terminal" error.

What is the way to attach to a potentially already existing tmux session on a remote machine, run commands and cleanly get the exit codes, stderr, stdout using fabric?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant