It's all about the answers!

Ask a question

Is it possible to use the ksh's for loop in BF console?


John Wang (1011612) | asked Jan 04 '11, 10:18 a.m.
I am trying to use a ksh for loop inside of BF console. Here is the syntax,

for f in $(find . -name *.xml); do
echo $f
done

I can't get the $f variable initialized.

Here is the output,

325 Tuesday January 4 2011 10:03:04AM GMT EXEC f
326 Tuesday January 4 2011 10:03:04AM GMT EXEC f

I am currently on BF 7.1.1.4.

4 answers



permanent link
Robert haig (1.0k16) | answered Jan 04 '11, 3:12 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
I am trying to use a ksh for loop inside of BF console. Here is the syntax,

for f in $(find . -name *.xml); do
echo $f
done

I can't get the $f variable initialized.

Here is the output,

325 Tuesday January 4 2011 10:03:04AM GMT EXEC f
326 Tuesday January 4 2011 10:03:04AM GMT EXEC f

I am currently on BF 7.1.1.4.


yes, you just have to add extra "$" to the front of your variable. There are multiple evaluations between the step command box and the actual execution that necessitate the multiplication of the '$' character on the front of an env var.

I'd suggest

for f in `find . -name *.xml`; do 

echo $$$$f
done

permanent link
John Wang (1011612) | answered Jan 04 '11, 3:43 p.m.
I am trying to use a ksh for loop inside of BF console. Here is the syntax,

for f in $(find . -name *.xml); do
echo $f
done

I can't get the $f variable initialized.

Here is the output,

325 Tuesday January 4 2011 10:03:04AM GMT EXEC f
326 Tuesday January 4 2011 10:03:04AM GMT EXEC f

I am currently on BF 7.1.1.4.


yes, you just have to add extra "$" to the front of your variable. There are multiple evaluations between the step command box and the actual execution that necessitate the multiplication of the '$' character on the front of an env var.

I'd suggest

for f in `find . -name *.xml`; do 

echo $$$$f
done


Thanks that worked, however, I was trying to use for loop to launch multiple jobs.

for f in `find . -name *.xml`
do
.set MYENV "MYXML=$$$$$f"
.run "MYProject"
done

I would get the following error.


312 Tuesday January 4 2011 03:37:05PM GMT EXEC ksh[3]: 0403-057 Syntax error at line 3 : `for' is not matched.




permanent link
Robert haig (1.0k16) | answered Jan 04 '11, 4:19 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
I am trying to use a ksh for loop inside of BF console. Here is the syntax,

for f in $(find . -name *.xml); do
echo $f
done

I can't get the $f variable initialized.

Here is the output,

325 Tuesday January 4 2011 10:03:04AM GMT EXEC f
326 Tuesday January 4 2011 10:03:04AM GMT EXEC f

I am currently on BF 7.1.1.4.


yes, you just have to add extra "$" to the front of your variable. There are multiple evaluations between the step command box and the actual execution that necessitate the multiplication of the '$' character on the front of an env var.

I'd suggest

for f in `find . -name *.xml`; do 

echo $$$$f
done


Thanks that worked, however, I was trying to use for loop to launch multiple jobs.

for f in `find . -name *.xml`
do
.set MYENV "MYXML=$$$$$f"
.run "MYProject"
done

I would get the following error.


312 Tuesday January 4 2011 03:37:05PM GMT EXEC ksh[3]: 0403-057 Syntax error at line 3 : `for' is not matched.





you cannot use dot-commands from within shell commands. the steps are broken up into pieces prior to, containing, and after the dot-commands.

that's why you get a syntax error... the for and do line are in their own shell.

I think .load might work for you though. You can dynamically create a step and execute it.
http://publib.boulder.ibm.com/infocenter/bldforge/v7r1m2/index.jsp?topic=/com.ibm.rational.buildforge.doc/topics/dotcmd_load.html

The .load command loads a project from an XML file and adds the steps of the loaded project to the current project, after the step that executed the .load command, allowing a project to dynamically create and load steps at run time. Using options, you can cause the .load command to draw its data from a register or from the output of a command.

permanent link
John Wang (1011612) | answered Jan 04 '11, 4:42 p.m.
Thank you very much for your input..

I have found a workaround for my problem.

Basically, I create a queue file containing the list of files to be processed. I wrote a popQueue script to pop the first item of the queue and set it in the env variable. Then, I create a while-loop conditional step command checking the variable. After each .run, I do another pop and set command to get ready for the next launch. The while-loop will stop when there is no more file in the queue.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.