Link to home
Start Free TrialLog in
Avatar of John Sheehy
John SheehyFlag for United States of America

asked on

Open multiple terminal windows using a script and running a script in the new xterm

Is there a way to run a script in UNIX  that opens 4 extra terminal windows and executes a specific script in each window?
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Why would you want to open extra terminal windows?
bash has a builtin background job control feature, so you can easily run multiple scripts in parallel.

Example script "master.sh":

#!/bin/bash
script1.sh > script1.log 2>&1 &
script2.sh > script2.log 2>&1 &
script3.sh > script3.log 2>&1 &
script4.sh > script4.log 2>&1 &

Please note the ampersands "&" at the line ends! They're telling bash to run the scripts in the background.
You can check the results of your scripts by reviewing the log files (see above "script1.log" ... etc.) after completion or even during execution.
You can see all your running background jobs by issuing the command "jobs".


How to open terminal windows heavily depends on your environment.
I'd need a very detailed description of it to assist you here.
Avatar of John Sheehy

ASKER

The script I run has a menu with 6 options.  Options 1-5 are for single systems.  Meaning the operator only wants to run that script on a particular machine.  Option 6 allows a particular script to be ran on multiple machines.  

The reason for the windows is, you need to log in to each machine every time a file is copied (SCP) and every time a script on that remote host needs to run.

So it goes like this now:

User choose option 6.
User logs into first system in host file. A file is copied to remote host, logs back in and a script is ran on remote host.  

This process repeats 5 more times for 5 particular systems.  each system has latency added so SCP time vary from 1 minute to 10 minutes for any given systems.

So imagine logging into 5 different times and the system takes 50 min to copy a file.  If multiple windows could be opened and ran a particular script I could copy the file to multiple systems all at once.

Make sense?
John
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have no idea how to use public/private key authentication.  And yes they all sit behind a graphical desktop.  UNIX SOL 10.
Solaris comes (among others)  with GNOME. What do you get with

gnome-terminal

?
See this EE article about SSH/SCP/SFTP authentication (Thx, Kerem!)

https://www.experts-exchange.com/articles/788/SSH-access-using-public-key.html
The answer given was the right one and took me sometime to become really familiar with public/private keys.  This one answer alone has saved me numerous hours and allowed me to focus on other important tasks.

John