Topic
  • 2 replies
  • Latest Post - ‏2010-10-08T11:12:41Z by sgalante
sgalante
sgalante
10 Posts

Pinned topic Using .bset to set env variable based on file exists

‏2010-10-07T15:58:38Z |
I am trying to use .bset in a step to set a environment variable to true or false based on the result if a file exists or not. I am attempting to use a UNIX command that equates to this: $ http:// -e /usr/local/spapp/sprdeploy/simjars/patch/QA02/Domain.ear

I have a environment varaible named FileExists set in the projects environment. I know that the variable used in the .bset command won't be changed until the next step, but I can't get the env variable to set correctly. The statement is filling in the ${MACHINE} variable in the first step below, but instead of setting FileExists to true or false, the results in the LOG show:
.bset env 'FileExists' = '($ http:// -e /usr/local/spapp/sprdeploy/simjars/patch/QA02/Domain.ear )'
Current setup for testing

Step 1 - .bset env "FileExists=($ http:// -e /usr/local/spapp/sprdeploy/simjars/patch/${MACHINE}/Domain.ear )"
Step 2 - echo ${FileExists}

What I really need to do, is to set the second step up as a Conditional Step based on true or false so in effect, I would end up with something like this in pseudo code:

Step 1 - (set FileExists variable to true if file exists, false if it doesn't)
Step 2 - If True
Do this
Else
BLANK (Do nothing)
Any help is greatly appreciated.
Updated on 2010-10-08T11:12:41Z at 2010-10-08T11:12:41Z by sgalante
  • SystemAdmin
    SystemAdmin
    805 Posts

    Re: Using .bset to set env variable based on file exists

    ‏2010-10-07T16:06:55Z  
    Your .bet command should look like this:

    .bset env "FileExists=`whatever unix command you want`"

    Looks like you are missing the backquotes.
  • sgalante
    sgalante
    10 Posts

    Re: Using .bset to set env variable based on file exists

    ‏2010-10-08T11:12:41Z  
    Your .bet command should look like this:

    .bset env "FileExists=`whatever unix command you want`"

    Looks like you are missing the backquotes.
    Thank you Leo.

    That did the trick. It took me awhile to prove your answer worked though, becuase I was trying the ' character instead of the ` character, also once I got my Unix command correctly written, it worked great.