I'm pretty new to shell scripts but I have some binaries I'd like to run in a loop over a set of different input files. I need them to be run in sequence: repeat after current one complete.
I got as far as trying to run two process in separate terminals and saving the pid but when I go to kill the process, it looks like the pids have changed.
#!/bin/bash
gnome-terminal -e "vi" & MAIN_PID=$!
gnome-terminal -e "gedit" & SIM_PID=$!
echo "MAIN Process ID is " $MAIN_PID
echo "SIM Process ID is " $SIM_PID
sudo kill $MAIN_PID
Terminal Output:
MAIN Process ID is 8532 SIM Process ID is 8542 # Option “-e” is deprecated and might be removed in a later version of gnome-terminal. # Use “-- ” to terminate the options and put the command line to execute after it. kill: (8532): No such process user:~/Desktop$ ps -A | grep vi 1026 ? 00:00:01 dconf-service 8541 pts/3 00:00:00 vi user:~/Desktop$ ps -A | grep gedit 8550 pts/4 00:00:00 gedit
If there's an easier way to get what I want started, I'd like to know as well. I was planning to start these processes and check some condition to know when they have completed, kill the process and repeat with different set of inputs.