Reputation: 11
How can I retrieve control-m JOBNAME in unix shell (ksh) script
From what I read %%JOBNAME
should give me the JOBNAME but unix does not support %%JOBNAME
. I tried it but not successful
Also I tried using $JOBNAME
but it did not work either
Upvotes: 1
Views: 4266
Reputation: 45
the easiest way is to define a parameter in the job that submits the unix task. Name the parameter PARM1 (or PARM2) and give it the value %%JOBNAME. in the unix script, you'll access the value with $1 (or $2).
Upvotes: 0
Reputation: 11
First you will have to get your local %%JOBNAME
variable into a global variable, you can do that pretty easily from within the job form.
Once you have a global variable, there is a ctmvar utility included with the CTM Server/Agents. You can use that to read in Control-M global auto edit variables into script-able shell environments like bash as follows:
UNIXVAR=$(ctmvar -action list | grep %%CTMGLOBALVARIABLENAME | awk '{print $2}')
To do the reverse and set a CTM global variable from a unix shell variable do this:
ctmvar -action set -var "%%\CTMGLOBALVARIABLE" -varexpr "$UNIXVAR"
I do this all the time in shell scripts and it works great. The one caveat is that once you set a global variable is it visible to all agents and all servers by the same variable name, so be careful you use unique variable names so you don't step on your own toes, and also that you clean up after yourself or you will have a ton of global variables left lying about.
Upvotes: 1