I've faced a problem with runtime variables in control-m.
I have to migrate some powershell scripts to linux shell, and it doesn't work same way during the execution.
In general, powershell script looks like this:
write-HOST "SOME_VARIABLE_NO2=OTHER_VAL2"
write-HOST "SOME_VARIABLE_NO3=OTHER_VAL3"
write-HOST "SOME_VARIABLE_NO4=OTHER_VAL4"
Linux script is
#!/bin/sh
echo "SOME_VARIABLE_NO2=OTHER_VAL2"
echo "SOME_VARIABLE_NO3=OTHER_VAL3"
echo "SOME_VARIABLE_NO4=OTHER_VAL4"
Now, during execution I have the following outputs
- For Powershell:
>SOME_VARIABLE_NO2=OTHER_VAL2
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO2' ==> 'OTHER_VAL2']
>
>SOME_VARIABLE_NO3=OTHER_VAL3
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO3' ==> 'OTHER_VAL3']
>
>SOME_VARIABLE_NO4=OTHER_VAL4
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO4' ==> 'OTHER_VAL4']
- For Linux
>SOME_VARIABLE_NO2=OTHER_VAL2
>SOME_VARIABLE_NO3=OTHER_VAL3
>SOME_VARIABLE_NO4=OTHER_VAL4
>
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO3' ==> 'OTHER_VAL3']
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO2' ==> 'OTHER_VAL2']
>[Extracted runtime parameter: 'RT_SOME_VARIABLE_NO4' ==> 'OTHER_VAL4']
How can I make bash and control-m to perform same way as ps1&control-m? Is this matter of control-m configuration?
In powershell write-host command could assign a variable value just after executing this line. In bash the whole script has to execute before the variable value is beign assigned. I'm looking for solution that allows control-m to assign variable in bash as it works in powershell - after executing particular line
I need those variables during the execution, because they store e.g PID of process, so that I can kill it (for whatever reason)
I must admit, that I have no idea how control-m works. I can ask question to person who has access, but at this point I don't even know what to ask..
Best practice, in this case, is to use the Control-M Job Definition to store your variables.
In the Job Def, halfway down the first tab, is the Variables field. Here you can use the %%PARMn special Control-M Variable as below -
Type ....... Name ................................. Value
Local ...... SOME_VARIABLE_NO1 .... OTHER_VAL1
Local ...... SOME_VARIABLE_NO2 .... OTHER_VAL2
Local ...... SOME_VARIABLE_NO3 .... OTHER_VAL3
Local ...... PARM1 ............................... SOME_VARIABLE_NO1
Local ...... PARM2 ............................... SOME_VARIABLE_NO2
Local ...... PARM3 ............................... SOME_VARIABLE_NO3
Local means the scope of the variable is limited to this one job/script (you can use different scopes, all the way up to Global).
The values %%PARM1, %%PARM2, etc will be reflected by $1, $2 and so on.
BMC have this video guide on their channel -
https://www.youtube.com/watch?v=nPKbOh8tUNU
there is a good guide here too -
https://communities.bmc.com/message/832637#832637