Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Buildforge .bset - set variable as output of OS command

I am trying to define a buildforge command where I read a text file and want to assign the second line of the file to a variable.

According to Buildforge on-line help document this should be possible.  But i can't seem to get it working

e.g. my text file contains 2 lines

    1. Websphere Version
    2. ws7

I wish to assign text from second line to a variable, so I tried

.bset env "WS_VERSION_CAT[1] = `cat ${BF_ROOT}/wsVersion.txt`"

but the output I get is

409     6/10/13 7:59 PM        ENV     WS_VERSION_CAT[1]=Websphere Version:ws7

I was expecting the output to be just ws7

Also, how do I access this variable in next step?

Thank you

0 votes



One answer

Permanent link
 The 'cat' command will display the entire file.  So you would want to pipe it to sed to get a specific line number, so something like  `cat ${BF_ROOT}/wsVersion.txt | sed -n '2p'`.  The variable should be accessible then in the next step by using ${WS_VERSION_CAT[1]}

~Spencer

0 votes

Comments

I will try this approach, but why does it not work the way I have as mentioned in the link - Buildforge on-line help document ?

By default, the system assigns the entire output of a command in backticks to the variable, but you can use range commands in brackets to select which lines from the command output you want to assign to your variable. The range numbers specify lines from the output using a 0-index  (the first line is numbered zero, the second 1, etc.). In the following example,

.set env SetupGroup "WindowsIPinfo[0,5-8]=`ipconfig`"

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,023
× 3

Question asked: Jun 10 '13, 8:15 p.m.

Question was seen: 7,390 times

Last updated: Jun 12 '13, 5:23 a.m.

Confirmation Cancel Confirm