Project and Portfolio Management Practitioners Forum
cancel

Set token to UNIX variable

Highlighted
Tommy Honahan
Trusted Contributor.

Set token to UNIX variable

Hi All,

I'm trying to set a token in one of my object commands to the value of a UNIX command output.

For example, let's say I have a token [P.P_TEST] and I have a variable in my UNIX session called v_test with a value of "Blah".

I basically want to do:

[P.P_TEST] = $v_test

I thought I could use ksc_capture_ouput, but you can't specify where to capture the output - in this case a token.

Any ideas?
3 REPLIES
Erik Cole
Acclaimed Contributor.

Re: Set token to UNIX variable

Hi Tommy,

You can use ksc_set to set a temporary token, but I don't know about setting a value for an existing, "hard" token...

ksc_local_exec echo $v_test
ksc_set TEMP_TOKEN="[EXEC.OUTPUT]"

Since its lifespan is until all the commands in your object type are executed, you could later use it in another command, like:

ksc_local_exec echo "[TEMP_TOKEN]"

...or whatever. Hope this helps.
Jason Nichols K
Acclaimed Contributor.

Re: Set token to UNIX variable

Tommy,

Like ksc_set, ksc_store will write a new value to one of the parameter tokens. This stores it permanently in the database so the scope of the value is not limited to the single execution step.

Jason
Tommy Honahan
Trusted Contributor.

Re: Set token to UNIX variable

Thanks guys.

Erik - I ended up doing pretty much what you said, but rather then using ksc_local_exec, I just did:

echo $v_test
ksc_set TEMP_TOKEN="[EXEC.OUTPUT]"

Otherwise I was getting an error saying I had to first close the connection to my destination server, in which case I would lose the variable. Learning about EXEC.OUTPUT was huge... thanks.