I am trying to run 2 commands, using the "for x in a b c d" loop but i am having a hard time coding it...
Here is what i have so far:
for SERVER in SERVERA SERVERB SERVERC SERVERD SERVERE
do
###############################################################################
# Launching the first backup...
###############################################################################
echo ${LOGIN} "GENERATE BACKUPSET ${SERVER}
###############################################################################
# Launching the second backup
###############################################################################
echo ${LOGIN} "GENERATE BACKUPSET ${SERVER}
###############################################################################
# Waiting for the first pair to complete...
###############################################################################
while (( $( ${LOGIN} q proc | grep "GENERATE BACKUPSET" | wc -l) != 0 ))
do
echo ".\c"
sleep 60
done
done
What i am trying to do, is get the loop to run the GENERATE BACKUPSET SERVERA and SERVERB at the same time. Then wait using the while loop at the bottom. Once those 2 are completed (while loop would exit) it should keep going to GENERATE BACKUPSET SERVERC and SERVERD and so on...I've inserted "echo" in the front for debug purposes...
What i am getting though, is a GENERATE BACKUPSET SERVERA twice instead...
I tried to issue a "continue" but that did not work either...
Script posted by kshji itself working fine.If you face problems with assigning values to an array.Then,assign the values to an array using the following way.
i=0
for x in SA SC SE
do
backup1[$i]=$x
let i=i+1
done
i=0
for x in SB SD SF
do
backup2[$i]=$x
let i=i+1
done
for((x=0;x<$i;x++)) #This is for checking and printing the array values
do
echo "Back Up1 Values:${backup1[$x]}"
echo "Back Up2 Values:${backup2[$x]}"
done
Sorry, my term "posixsh" is not good in this case. This kind of array init is not in posix defination.
Many of current sh support it. Like ksh93, bash, zsh, ... but not in dash which is posix-sh without extension.