Below for loop not exiting. Can someone help?
JBOSS_INST_ARGS=01 02
if [ "$JBOSS_CMD_TYPE" = "start" ]; then
for i in $JBOSS_INST_ARGS; do
/u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start;
done
Below for loop not exiting. Can someone help?
JBOSS_INST_ARGS=01 02
if [ "$JBOSS_CMD_TYPE" = "start" ]; then
for i in $JBOSS_INST_ARGS; do
/u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start;
done
Sound silly - but have you remembered to add a final fi to close the if statement.
Also, try using braces for $i:
/u/jboss-6.1.0.Final/bin/jboss_init_wise${i}.sh start;
JBOSS_INST_ARGS=01 02
if [ "$JBOSS_CMD_TYPE" = "start" ]; then
for i in $JBOSS_INST_ARGS; do
/u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start;
done
fi
i missed to add fi in the post, but it contains in actual script.
Also, JBOSS_INST_ARGS="01 02"
Have you tried putting diagnostic echo statements in the script to see if the script gets as far as the second iteration?
What's in this script?
If it's a daemon, perhaps it needs starting as:
nohup /u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start &
No. Its doesn't exit the loop even after the changes.
Test the loop by just calling a pwd and make sure the loop exits:
if [ "$JBOSS_CMD_TYPE" = "start" ]; then
for i in $JBOSS_INST_ARGS; do
pwd
done
fi
If this succeeds, then you need to investigate the script that it is calling - is it exiting? Try running it outside the for loop and see if it hangs.
Yes, the issue with the
it hangs. But I tried
, still no luck.
If /u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start hangs, then that is where the problem lies. You have to examine that script to see why. Try running it with a debug flag - e.g. if it's a korn shell script try
ksh -x /u/jboss-6.1.0.Final/bin/jboss_init_wise$i.sh start
then you should be able to see where it's hanging