Antoine_Sauteron_1266

Storing Unix command output in a variable

Discussion created by Antoine_Sauteron_1266 on Jul 18, 2017
Latest reply on Jul 18, 2017 by Michael_Lowry
I am looking for output of Unix command to be stored in any variable. Generally we use POST process to do so , however , as this is "INCLUDE" object I am not able to store.
PUT_VAR does not work as that stores the command itself - not command output.

1. You may use PREP_PROCESS in the INCLUDE object to run an OS command  :
:SET &HND# = PREP_PROCESS("&$AGENT#","UNIXCMD",,"CMD=echo $SHELL","UC_LOGIN=&$LOGIN#")
:PROCESS &HND#
:  SET &SHELL# = GET_PROCESS_LINE(&HND#)
:  P &SHELL#
:ENDPROCESS

2. You can also use a BACKEND variable to run the command, then collect its output with GET_VAR or PREP_PROCESS_VAR in the include object as well.

ahbjvixfnyld.png

INCLUDE
:SET &SHELL# = GET_VAR(VARA.BACKEND.UNIX.CMD)
:P &SHELL#

Here's the output:
diuwekkeeil6.png

I'm attaching an xml export of example objects.

Best regards,
Antoine

Outcomes