WindTerm icon indicating copy to clipboard operation
WindTerm copied to clipboard

[Feature Request] Automatically run User-defined Script when Session opens

Open pytkr opened this issue 2 years ago • 4 comments

Hello! When I open an existing session to a remote server, I hope it can automatically run pre-defined scripts, such as:

  1. open certain file, e.g., cat ~/.bash_profile
  2. open some dynamic command, e.g., watch -n 1 "ps -ef | grep -v grep | grep mysqld" or watch -n 1 "ip a s"

Thus, when I restart windTerm, the whole groups I created and each session in each can be the same before windTerm restart.

pytkr avatar Jul 11 '22 09:07 pytkr

Welcome. Is Session Settings Dialog - SSH - Authentication - Execute command after authentication what you need?

kingToolbox avatar Jul 11 '22 21:07 kingToolbox

Welcome. Is Session Settings Dialog - SSH - Authentication - Execute command after authentication what you need?

Thanks for your reply!

I tried to config Execute command after authentication to execute, e.g., ip a. However, when windTerm restarts, ip a shows in the console unexecuted, unless I press enter in this session.

If I use ssh [email protected] ; ip a or ssh [email protected] && ip a, when I press enter, the second command ip a cannot be executed, nor does it show in the console.

If I open two views of the same server ip side by side, when windTerm restarts, both of them are shown with the same command.

Sum it up:

  1. command needs to be executed automatically after successful authentication;
  2. multiline scripts also needed, e.g, commands in Quick Commands can be reused here;
  3. each view of the same server ip needs to be configurable, to run different commands.

Thanks!

pytkr avatar Jul 12 '22 03:07 pytkr

However, when windTerm restarts, ip a shows in the console unexecuted, unless I press enter in this session.

You need to add \n at the end - ip a\n.

ssh [email protected] ; ip a or ssh [email protected] && ip a,

In both of these examples the ip command would get executed on the local machine after the ssh connection is terminated.

This is probably what you are looking for ssh [email protected] -t 'ip a; bash -l'.

GithubUser5462 avatar Jul 13 '22 07:07 GithubUser5462

However, when windTerm restarts, ip a shows in the console unexecuted, unless I press enter in this session.

You need to add \n at the end - ip a\n.

ssh [email protected] ; ip a or ssh [email protected] && ip a,

In both of these examples the ip command would get executed on the local machine after the ssh connection is terminated.

This is probably what you are looking for ssh [email protected] -t 'ip a; bash -l'.

Thanks for you suggestion, I succeed to run ip a\n after authentication, so my suggestion 1 has been resolved. However, every terminal with the same server ip ran the same command ip a\n. So my suggestions are still here:

  1. multiline scripts also needed, e.g., commands in Quick Commands can be reused here;
  2. each view of the same server ip needs to be configurable, to run different commands.

Thanks!

pytkr avatar Jul 18 '22 07:07 pytkr