Search code examples
bashmultiplexing

Bash Script: Split screen + launch programs remotely


I've been using a bash script for monitoring and auditing purposes on local machines. It relies on multiple external programs that are launched automatically to gather, display and save information.

To achieve this I(the script)'ve been using a combination of xterm and timeout like so:

sudo timeout 300 xterm -hold -geometry "150x50+400+0" -xrm 'XTerm*selectToClipboard: true' -e "external-program --some-arg -o ..."

It works fine however, I would like to run this script on a remote machine using SSH (from Windows or Mac) and I can't / don't want to have xterm / X11 forwarding to make it work.

Is it possible to use the screen, tmux (or similar / something built) in my script to automatically split the screen of the SSH session and launch the external programs in those instead of xterm? Better yet if I could remotely attach and detach from it at any point.

Thank you.


Solution

  • Tmux is an excellent choice for that. Here is an example for extending gdb-dashboard. Basically you just write a bunch of tmux split-window '<your-awesome-script>' and it works.