I want to store the output of a Bash command in an Automic variable in Automic 12.1. I browsed these community pages and saw a few references to REGISTER_VARIABLE. I wrote a script to test this and am not quite getting the result I expect.
:DEFINE &TEST#, string:BEGIN_EXT_INT BASH:REGISTER_VARIABLE TEST#,$ORACLE_HOME:END_EXT_INT BASH:PRINT "Variable output: &TEST#"
In my report, I see the following message:
Registered variable: 'T' TEST#=[valid path]
However, the &TEST# variable appears to still be empty as the PRINT function only printed
I'm new to Automic, so there's probably just something simple I'm missing.
Thanks in advance.
For Bash you do not need an external interpreter.
In a Unix Job its fair enough using e.g. :REGISTER_VARIABLE TEST#,$HOME
The Variable &TEST# is available in POST_PROCESS, NOT in Process.
Reason: Automic Script is processed prior all JCL (=OS) commands
So in your case it does first Print &TEST# - empty!and afterwards the register command on OS..
=> Put the print to Post_Process, delete the BEGIN_EXT... section and it will work.
Simple Example - unix Job, process::REGISTER_VARIABLE TEST#,$HOMEPost_process::PRINT "Test: &TEST#"
Report:Registered variable: 'T' TEST#=/home/uc4Post_Process:2018-04-20 14:38:44 - U00020206 Variable '&TEST#' was stored with value '/home/uc4'.2018-04-20 14:38:44 - U00020408 Test: /home/uc4