I am looking for a way to automate the launch of my development environment. I have three virtual machines that need to be started, then I need ssh for each of them and open a VPN on them.
So far, I got them to run and got ssh for them:
#!/bin/sh virsh start virtual_1 virsh start virtual_2 virsh start virtual_3 sleep 2m gnome-terminal --title "virtual_3: server" -x ssh root@192.168.1.132 & gnome-terminal --title "virtual_2: 11.100" -x ssh root@192.168.11.100 & gnome-terminal --title "virtual_1: 12.100" -x ssh root@192.168.12.100 &
How to execute an additional command on each of the terminals that run openvpn?
For simplicity, I try echo 1 in each terminal instead of starting a VPN.
I found that you can run several commands when starting the terminal, for example:
gnome-terminal -x bash -c "cmd1; cmd2"
So, for one terminal, to be simple, I changed:
gnome-terminal --title "virtual_3: server" -x ssh root@192.168.1.132 &
in
gnome-terminal --title "virtual_3: server" -x bash -c "ssh root@192.168.1.132 ; echo 1" &
But 1 not printed in terminal virtual_3. Then I thought, maybe the command runs too fast until the terminal is ready, so I tried adding && :
gnome-terminal --title "virtual_3: server" -x bash -c "ssh root@192.168.1.132 &&; echo 1" &
But this also did not produce a result.
bash
TheMeaningfulEngineer
source share