Linux: How to open multiple xterm windows while running a command in bash
My goal was to ssh to several servers at the same time. I wanted to open a new terminal for each connection. Then within the terminal, run a separate bash session launching my ssh connection. You have to launch within bash if you want to be able to continue using the terminal session after you exit your ssh session. I also wanted each terminal window to open at a different location on my screen,
The code below does the following
1. Generates six random horizontal numbers
2. Generates six random vertical numbers
3. starts each xterm application at random location, launching the command inside of a bash shell.
#!/bin/bash
data=($( shuf -i 75-1000 -n 6))
data2=($( shuf -i 75-450 -n 6))
#echo ${data[1]}
#echo ${data[2]}
xterm -geometry 150×32+${data[1]}+${data2[1]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[2]}+${data2[2]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[3]}+${data2[3]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[4]}+${data2[4]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[5]}+${data2[5]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[6]}+${data2[6]} -e bash -c ‘command; bash’ &
By: nighthawk