operating-system - 如何在 Openedge 中包含具有替换功能的 OS 命令?
问题描述
我试图通过 OpenEdge 中的 OS-Command 创建 PDF,但在运行脚本时遇到错误。
*错误:命令“C:\ Program”拼写错误或找不到
它完美地工作:
os-command (' "C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe" "V:\V11\WEB\PDF\Name_01.03.2021_14.09.30_da.html" "V:\V11\WEB\PDF \Name_01.03.2021_14.09.30_da.pdf"')。
但是,当我在脚本中包含命令并运行它时,我遇到了一个错误。
这个不起作用:
将变量 cmdcommand 定义为 char no-undo。cmdcommand = SUBSTITUTE (' "C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe"
"V:\V11\WEB\PDF\Name_&1_&2_&3.html"
"V:\V11\WEB\PDF\Name_&1_&2_&3.pdf" ' ,“01.03.2021”,“14.09.30”,“da”)。操作系统命令值(cmdcommand)。
我在这里错过了什么?任何人都可以帮忙吗?
解决方案
经过os-command
一段时间的努力以得到正常错误并返回输出,如果您只针对 Windows,那么您可能会发现使用 .Net System.Diagnostics.Process类更容易。
为了让你开始:
define variable oProcess as System.Diagnostics.Process no-undo.
define variable oInfo as System.Diagnostics.ProcessStartInfo no-undo.
oProcess = new System.Diagnostics.Process().
assign
oInfo = oProcess:StartInfo
oInfo:FileName = "C:~\Program Files (x86)~\winmerge~\winmergeu.exe".
oInfo:WorkingDirectory = "session:temp-directory
oInfo:Arguments = substitute(
"&1 &2",
quoter( "file1.txt" ),
quoter( "file2.txt" )
)
.
oProcess:Start().
oProcess:WaitForExit().
ProcessStartInfo类的其他有用属性包括:
- 创建无窗口
- 使用Shell执行
- 重定向标准错误
- 重定向标准输出
推荐阅读
- apache-spark - 在 Spark 中读取使用 PartitionBy 或 BucketBy 写入的文件
- csv - 关于具有给定参考/引用数量的论文数量的问题
- python - sns.Facetgrid 未显示正常分布线并忽略空间警告
- linux - 查找过去 24 小时内仅修改过一次的文件
- javascript - 删除 Div Wrapper 或更改嵌套地图中某些分组元素的类名称
- c++ - 用推导类型声明类成员
- javascript - 如何从一个js文件访问一个变量到另一个js文件,两个js文件都在android studio的不同html文件中?
- python - 如何使用 Google Ads API 和 Python 更改关键字状态
- scala - 是否可以在 scala 中展平这个特定的序列?
- r - r - 在 dplyr 函数中传递存储在变量中的字符串