I want to have a script that first connects me to a remote pc with ssh and executes some commands there. These commands start a process, which will run forever (stops with user input). Now, I must run some commands on my local pc (unfortunately, it's not possible to run them before ssh'ing). So my thoughts are to open a new terminal before connecting to remote, then run ssh and the commands, and then switch back to the terminal in local and execute the rest of the commands. The two inputs are the port on the remote and the port on the local.
Till now, my script looks like follow:
#!/bin/bash echo "Connecting to server" ssh -t -t <name>@ip << EOF cd /path/to/directory && conda activate <environment_name> && tensorboard --logdir=<log/directory> --port $2 EOF echo "Connected" gnome-terminal -e exit echo "Connecting with localhost" ssh -N -f -L localhost:$1:localhost:$2 <name>@ip
But this does not work. I only get connected to the remote, and it's not possible to open a xterm afterwards, because tensorboard is constantly running. So, how to open a terminal beforehand and switch back to it?
Or any other suggestion how to solve this issue?
Many thanks in advance!