LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Execute programs in multiple terminals using a Shell Script (http://www.linuxquestions.org/questions/linux-newbie-8/execute-programs-in-multiple-terminals-using-a-shell-script-900989/)

kapz_unlocked 09-04-2011 01:34 AM

Execute programs in multiple terminals using a Shell Script
 
Hello all,

I have three java programs to wait on three sockets. I want to write a Shell Script to execute all three at once in three different terminals. Making the backgroung won't help as I want to track the outputs of three programs separately.

Is this possible? Or is there any other way to do this?
Please help!
Thanks in advance

timothyb89 09-04-2011 03:35 AM

You could redirect the output of each to a file and monitor it with something like tail:

Code:

program1 >> program1.log 2>&1 &
program2 >> program2.log 2>&1 &
program2 >> program3.log 2>&1 &

Then in separate terminals:
Code:

tail -f programX.log
With that you can start them from a single terminal, and monitor them separately.

Alternatively you could have a script launch a new instance of your terminal emulator of choice for each program:

Code:

konsole --noclose -e program1 &
konsole --noclose -e program2 &
konsole --noclose -e program3 &


kapz_unlocked 09-04-2011 03:55 AM

Thanks timothy! But I solved the problem using 'gnome-terminal':

Quote:

#! /bin/bash

cd /root/ESSR_log/JavaRun

javac ServerInputChunks.java
gnome-terminal -e "java ServerInputChunks"

javac GetRequestedFiles.java
gnome-terminal -e "java GetRequestedFiles"

javac ServerDeleteRequest.java
gnome-terminal -e "java ServerDeleteRequest"
This is what I exactly needed :)


All times are GMT -5. The time now is 11:24 PM.