I have a program called mdr-dev
that I execute and that as a result opens port 1022.
After opening that port, I have to leave the program running to keep that port open. The snag is that it takes some time to execute so in the mean time I should wait for it to open that port!
Once the port is open, I want to open a new terminal and ssh
through that port to a remote device.
The question is: How to write a bash or any other script for this?
(I already tried with the sleep command but it does not seem to work.)
Here is what I've tried so far:
#!/bin/bash
echo $MDR_ROOT
mdr-dev --root --mount /opt/tile/home /home --tunnel 1022 22
After the mdr-dev
command above's initialisation process, I want to automatically open a new terminal and run:
ssh -p 1022 root@localhost
Off course, I already tried:
--tunnel 1022 22 &
sleep 5m
xterm -hold -e ssh -p 1022 root@localhost
but that doesn't seem to work...
How should I proceed?
mdr-dev
command and upon its completion open new terminal window withssh
? Why you cannot just addxterm
command at the end of the script ? Also, command for xterm should bexterm -hold -e 'ssh -p 1022 root@localhost'
mdr-dev
actually do? How do you know it's finished?mdr-dev
after completion goes into interactive mode. I can suspend only after its complete initialization and it takes some time. So I wait till its initialization is done and then open a new terminal and runssh -p 1022 root@localhost
in the new terminal--root
is one the options fed to it. It must be kept running after the initialization so I want to keep it running and open new terminal to dossh
&
:mdr-dev
keeps on running and that allows you tossh
in parallel... It's unclear to me what you're trying to accomplish here. Why don't you want&
?