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

Start tmux session for S&C from BakingTray menu #438

Open
raacampbell opened this issue Oct 12, 2022 · 1 comment
Open

Start tmux session for S&C from BakingTray menu #438

raacampbell opened this issue Oct 12, 2022 · 1 comment

Comments

@raacampbell
Copy link
Collaborator

raacampbell commented Oct 12, 2022

System settings file should contain analysis machine name and user name. There should be a shared SSH key from Windows command prompt to allow passwordless SSH to this account. From this it is possible to write MATLAB functions that do the following:

  1. Check that connection to the machine is possible.
  2. List available tmux sessions
  3. Find an existing tmux session named after the acquisition machine
  4. Open a command window, ssh to the machine, start tmux and attach to the existing seesion or create one named so.

Bonus points if we can first look through available open windows and find a window that already has the tmux connection open.

Should probably allow for multiple analysis PCs, just in case someone has a backup or something like that. So we add a friendly-name for each and import cell arrays from the YAML file. The first is the default. so, for example, we could have machineA then machineB in that order in the YAML. Then running bakingtray.syncandcrunch.checkDiskSpace will work on machineA and we could ask for machineB by suppling that as an input argument. That should future-proof us enough for now.

@raacampbell
Copy link
Collaborator Author

raacampbell commented Oct 28, 2022

Notes on getting this to work:

This seems to work from a Mac to Send command to remote tmux session:
https://unix.stackexchange.com/questions/716978/how-to-send-a-command-to-tmux-session-of-remote-device-using-ssh

Todo: test on Windows!

Add BT menu option to automatically start and open tmux session.

We can date stamp the syncandcrunch messages.

We can read the tmux buffer from Linux over SSH.

Process:
at windows prompt:

C:\Users\shopp>ssh-keygen
C:\Users\shopp>scp .ssh\id_rsa.pub rob@joiner.mrsic-flogel.swc.ucl.ac.uk:~/

Then copy contents into joiner .ssh/authorized_keys

Now in MATLAB this works!

>> system('ssh rob@joiner.mrsic-flogel.swc.ucl.ac.uk ls -l')

This starts a windows command prompt and lists files on joiner

start cmd /k ssh rob@joiner.mrsic-flogel.swc.ucl.ac.uk ls -l

This automatically connects to joiner
start cmd /k ssh rob@joiner.mrsic-flogel.swc.ucl.ac.uk ls -l

This connects to machine and starts a named tmux session

start cmd /k ssh  rob@joiner.mrsic-flogel.swc.ucl.ac.uk -t tmux attach -t test

Start MATLAB in a new tmux session and attach to it

$ tmux new-session -d 'matlab' \; attach

start MATLAB in a new tmux session in the background

$ tmux new-session -d 'matlab' \; 

Run a command in a tmux session named 'test'

tmux send-keys -t test 'ls -l' ENTER

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

No branches or pull requests

1 participant