expect - Bash script to wait for gnome-terminal to finish before continuing script, only works for first instance of script -
i have bash script opens new gnome terminal 2 tabs runs more scripts. after scripts in 2 tabs finishes, main script in parent terminal continues run.
when run multiple instances of bash script, no longer waits additional gnome-terminals finish before continuing parent terminal script.
how fix additional instances of script runs first one?
here bash script i'm running. run additional instances of typing sh scriptname.sh
in new terminal.
gnome-terminal --tab --command="expect launchneuron.exp" --tab --command="expect launchmpj.exp" echo "simulation complete" echo "plotting results" expect -c " set timeout -1 spawn ssh $username@server expect \"password\" send \"$password\r\" expect \"$ \" send \"qsub -i -q abc -a lc_tb -l nodes=1 -l walltime=24:00:00 -d .\r\" expect \"$ \" send \"sh plotgraph.sh\r\" expect \"$ \" send \"exit\r\" "
#!/bin/bash date bash -c "sleep 7" & bash -c "sleep 5" & wait date
as can see while running script, both sleep commands run in parallel, main thread stalls, while running.
sat. jule 27 01:11:49 2013 sat. jule 27 01:11:56 2013
replace sleep 7
expect launchneuron.exp
and sleep 5
expect launchmpj.exp
and add plot commands after calling "wait"
:
echo "simulation complete" ...(your code plot results)
Comments
Post a Comment