What I need to do is run a command 32 times; each command needs to have the slave and target specified. Some one decided on a goofy naming convention and there are 4 instances of the target on 8 slaves.
Skeleton of the command is:
execute.lng Slave01 Target01-A
execute.lng Slave01 Target01-B
execute.lng Slave01 Target01-C
execute.lng Slave01 Target01-D
execute.lng Slave02 Target02-A
...
execute.lng Slave08 Target08-D
Must've made sense to someone, but to me I would have prefered a nice easy to code sequence.
Psuedo code should be something like:
foreach instance ( A B C D)
foreach slave ( 1 2 3 4 5 6 7 8 )
do
execute.lng Slave0$slave Target0$slave-$instance
end
But it is Monday and my mind is mushy from head pounding :wall:so this of course is not working in ksh or bash...
The beauty of shell scripts is that it looks almost like a pseudo code.
The solution is almost exactly as you described:
#!/usr/bin/ksh
for mInstance in $(echo "A B C D"); do
for mServer in $(echo "1 2 3 4 5 6 7 8"); do
echo "mInstance <$mInstance> mServer <$mServer>"
done
done
Well rested eyes are helpful. Key is to see that sequencing all the A,B,C,Ds is easier way to tackle.
This looks pretty good from the echo:
#!/usr/bin/ksh
for mInstance in $(echo "A B C D"); do
for mServer in $(echo "1 2 3 4 5 6 7 8"); do
echo "excute.lng Slave0$mServer Target0$mServer-$mInstance"
done
done