Hi,
Test1.ksh
#! /bin/ksh
for i in $*
do
#echo "$i"
ksh test2.ksh $i &
done
test2.ksh
#! /bin/ksh
sleep 5s
echo "From Test 1 ==> $1"
exit 0;
I am executing as follows:
ksh test1.ksh a b c
Output is:
From Test 1 ==> a
From Test 1 ==> c
From Test 1 ==> b
After printing the last line its expecting the user to press the enter key to exit. Else its not quitting. How to quit that automatically ??
thanks in advance
use exit 1; at your functions' ends
Tired that too... Its not working .. It is expecting the user to press the enter key to exit back to the shell prompt.....
exit 0 <- will only work if error is encountered
Even without eixt its not working..
One thing you can do is this:
ksh test2.ksh $i > <filename> &
Re-direct your output to some other filename will solve the problem you mentioned but I don't know if this works for you..
cheers
thanks .. thats working ..
is there any other solution .. coz i may have a requirement like output should be displayed on the screen .. In that case your solution will not work ..
what I can think of at this moment is to kill the process at the end of your fuctions.. eg
PID=`ps -ef |grep Test | awk '{ print $1 }'`#ensure that PID is in column 1 ($1)
kill -9 ${PID}
All you have to do is insert "fg" in line after done in Test1.ksh file.
Your script are working in background; bring it into foreground to end.
#! /bin/ksh
for i in $*
do
#echo "$i"
ksh test2 $i &
done
fg
~/scripts/play % test1 a b c
From Test 1 ==> a
From Test 1 ==> b
From Test 1 ==> c
~/scripts/play %
Hi FunibonE...thanks...that works
hi funibone,
I am getting this error : test1.ksh[12]: fg: job control not enabled , when i added fg in test1.ksh
Also the test2.ksh did not start. Wat to do ??
hemant, can you please expalin how u tested that ??