在控制-M作业脚本中使用if else语句定义运行时变量是否可能?

huangapple go评论59阅读模式
英文:

Is it possible to define a runtime variable in a control-M job script using if else statement

问题

我正在尝试创建一个依赖于环境的Control-M脚本,因此我试图定义一个名为"folder"的变量,根据执行作业的环境获取一个值,然后将该变量"folder"在脚本的其余部分中使用。

以下是脚本,我的问题是Control-M无法读取"folder"变量。

提前感谢!

英文:

I am trying to create a control-M script that depends from the environment, so i am trying to define a variable called "folder" that gets a value, according to the env (where the job is executed) and that variable "folder" will be used in the rest of the script.

Here is the script, My problem is that control-M is not able to read the folder variable.

Thanks in advance 在控制-M作业脚本中使用if else语句定义运行时变量是否可能? !

在控制-M作业脚本中使用if else语句定义运行时变量是否可能?

答案1

得分: 1

我建议将其更改为将其作为参数捕获而不是参数/变量(即 $folder = $args[0] ),以便在 Control-M 作业中运行它。

还请注意,Control-M 有一种非常特定的方法来运行 PowerShell 脚本(除非您正在使用 Control-M 的最新版本,即 9.0.21$,在这种情况下它支持将 PowerShell 直接作为嵌入式脚本)。对于旧版本的 CM(9.0.21 之前的版本),请参阅此链接 -

https://community.bmc.com/s/article/How-do-I-run-a-Powershell-script-in-Control-M

英文:

I suggest switching it to have it to capture it as an argument rather than parm/variable (i.e. $folder = $args[0] ) for it to work within a Control-M job.

Also note that Control-M has a very specific method for running PowerShell scripts (unless you are using the latest version of Control-M, i.e. 9.0.21$, in which case it supports PowerShell directly as an embedded script).

For older versions of CM (prior to 9.0.21) see this link -

https://community.bmc.com/s/article/How-do-I-run-a-Powershell-script-in-Control-M

答案2

得分: 0

这是我修复的方法:if ( '"%%ENV_BATCH"' -eq '"PPD"' ) { $f = '"NASBUOPPD"'; } else { $f = '"BUOPRD"'; }。谢谢大家 :)!

英文:

This is how i fix it : if ( '"%%ENV_BATCH"' -eq '"PPD"' ) { $f = '"NASBUOPPD"'; } else { $f = '"BUOPRD"'; } . Thanks all :)!

huangapple
  • 本文由 发表于 2023年2月24日 17:19:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75554708.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定