Hi Chaps,
Can we assign an Environmetal variable to a Global variable in Control-M?
Nancy
Doubt
Hi,
I suggest to use the %%LIBMEMSYM parameter or the ctmvar utility.
If you used the %%LIBMEMSYM the file specified must reside on the Control-M/Server box and the full path must specified, like:
%%LIBMEMSYM=/controlm/ctm_server/your_path/your_autoedit_file
The usage for global variable the ctmvar is more flexible.
Usage: ctmvar -action set -var "%%\Variable_name" -varexpr "Global_variable_value"
Example: Put in your script
set My_Env_var=`hostname`
ctmvar -ACTION SET -var "%%\CTM_GBL_VAR1" -varexpr "$My_Env_var"
Now the %%CTM_GBL_VAR1 is a Global Variables for Controlm and all jobs can use it.
Don't forget to manage (delete) unused Global Variables at the end of the day.
If you want more detail go to see CONTROL-M Job Parameter and Variable Reference Guide.
I suggest to use the %%LIBMEMSYM parameter or the ctmvar utility.
If you used the %%LIBMEMSYM the file specified must reside on the Control-M/Server box and the full path must specified, like:
%%LIBMEMSYM=/controlm/ctm_server/your_path/your_autoedit_file
The usage for global variable the ctmvar is more flexible.
Usage: ctmvar -action set -var "%%\Variable_name" -varexpr "Global_variable_value"
Example: Put in your script
set My_Env_var=`hostname`
ctmvar -ACTION SET -var "%%\CTM_GBL_VAR1" -varexpr "$My_Env_var"
Now the %%CTM_GBL_VAR1 is a Global Variables for Controlm and all jobs can use it.
Don't forget to manage (delete) unused Global Variables at the end of the day.
If you want more detail go to see CONTROL-M Job Parameter and Variable Reference Guide.
Best regards
Walty
Walty
- nicolas_mulot
- Nouveau
- Posts: 149
- Joined: 07 Jan 2010 12:00
Nancy,
A good trick is to define those global variables every day using a service job, which runs daily.
Typically, this is a Dummy job which includes the following code:
ON STMT * CODE *
DO SETVAR %%\VAR1=<the>
In addition, some control-m parms can be directly specified as environement variable.
In your case, the value can be an environment variable.
I made a test like this, under windows:
ON STMT * CODE * DO SETVAR %%\COMP=%%COMPUTERNAME.
As a result, "ctmvar -action list" correctly displays the variable %%COMP with the name of my computer.
If you have a chance to make the test under Unix (which I dont have), pls let me know
Cheers
Nicolas_Mulot
A good trick is to define those global variables every day using a service job, which runs daily.
Typically, this is a Dummy job which includes the following code:
ON STMT * CODE *
DO SETVAR %%\VAR1=<the>
In addition, some control-m parms can be directly specified as environement variable.
In your case, the value can be an environment variable.
I made a test like this, under windows:
ON STMT * CODE * DO SETVAR %%\COMP=%%COMPUTERNAME.
As a result, "ctmvar -action list" correctly displays the variable %%COMP with the name of my computer.
If you have a chance to make the test under Unix (which I dont have), pls let me know
Cheers
Nicolas_Mulot
- nicolas_mulot
- Nouveau
- Posts: 149
- Joined: 07 Jan 2010 12:00
Nancy,
There was a slight mistake in my previous post.
Instead of:
ON STMT * CODE * DO SETVAR %%\COMP=%%COMPUTERNAME
.. which refers to an unexisting %%COMPUTERNAME AutoEdit variable,
One should have read:
ON STMT * CODE * DO SETVAR %%\COMP=%COMPUTERNAME%
.. which refers to the environment variable %COMPUTERNAME%
Sorry for that
Nicolas Mulot
There was a slight mistake in my previous post.
Instead of:
ON STMT * CODE * DO SETVAR %%\COMP=%%COMPUTERNAME
.. which refers to an unexisting %%COMPUTERNAME AutoEdit variable,
One should have read:
ON STMT * CODE * DO SETVAR %%\COMP=%COMPUTERNAME%
.. which refers to the environment variable %COMPUTERNAME%
Sorry for that
Nicolas Mulot