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

SSH on panes and run commands in the new shell #138

Open
bruno-rescale opened this issue Feb 21, 2023 · 1 comment
Open

SSH on panes and run commands in the new shell #138

bruno-rescale opened this issue Feb 21, 2023 · 1 comment

Comments

@bruno-rescale
Copy link

bruno-rescale commented Feb 21, 2023

Hi, I have the below itermocil template and it works partially. When I execute it, it opens 3 panes in the right layout and it runs an ssh command (from a variable) and logs in successfully. However the second and third panes do not run ps faux and top even after sleeping a few seconds. I noticed that once I exit those ssh sessions, the ps and top commands will run but I want them to run in the ssh'ed session. Is there a way to do this?

 windows:
   - name: quichssh
     root: ~
     layout: main-vertical
     panes:
       - commands:
         - ${ssh}
       - commands:
         - ${ssh}
         - sleep 2 && ps faux
       - commands:
         - ${ssh}
         - sleep 2 && top

I saw a prevoius post about adding -t flag to the ssh command but lets' assume i can't change ${ssh} as it's coming from another automated variable. As a last resource, I can try to parse and change ${ssh} and append -t as an additional argument if there is nothing else to do. But my priority is to see if there is an easier way. Thanks in advanced!

@cemiu
Copy link

cemiu commented Aug 28, 2024

While not useful for this exact issue, when the ssh command is known this can be used:

ssh <server> -t "bash -ic '<commands here, separated by semicolons>; bash -l'"
# e.g.: create ssh tunnel, load python env, then start jupyter server
ssh <server> -L 8810:cn50:8888 -t "bash -ic 'lpy; jupyter lab --ip 0.0.0.0 --no-browser; bash -l'"

It allows to run commands after loading .bashrc, then keeps the interactive shell alive.

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

2 participants