系统 cmd 指令的 dxl CreateProcess 失败
dxl CreateProcess failed for system cmd instruction
我想调用 运行 一个名为 csvplot.vbs (from this site) 的文件来转换我使用 dxl 编写的 .csv 文件(有 5 列,每列都有一个标题和然后只是数值数据)转换成图表(存储为 .png)。
我有 运行 直接通过 cmd 成功执行以下指令:
@echo off
cscript //nologo C:\Users\Administrator\csvplot.vbs C:\PROGRA~1\IBM\Rational\DOORS.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.csv C:\PROGRA~1\IBM\Rational\DOORS.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.png 800 600 1 3 1 4 1 5
pause
这将生成所需的 .png 文件。
然而,我想要的是能够通过 DOORS 执行此操作,以便每当生成原始数据的脚本是 运行 时,它也会生成一个图表。
我的测试用例是这样的:
string echostr = "@echo off"
string commands = "cscript //nologo C:\Users\Administrator\csvplot.vbs C:\PROGRA~1\IBM\Rational\DOORS\9.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.csv C:\PROGRA~1\IBM\Rational\DOORS\9.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.png 800 600 1 3 1 4 1 5"
system("cmd /c start @echo off") // doesn't recognise echo command
system("cmd /c start " commands "")
我收到一个错误:
"Windows cannot find '@echo'. Make sure you typed the name correctly,
and then try again."
我不知道如何通过 dxl 的 cmd 将脚本获取到 运行,如果有任何帮助,我将不胜感激。我之前只通过 dxl 尝试过一次 system() 提示,而且只是为了打开一个 .pdf。与此同时,我会继续努力解决这个问题。如果我可以提供任何进一步的信息,请告诉我。
编辑:更多信息
- @echo: 我删除了 @ 看看它是如何运作的,它带来了一片空白
cmd window 并且不执行进一步的操作。为了甚至运行下面几点的东西,我把@关掉了。
- 我从第二个 system() 行中删除了“/c start”:这会打开一个命令行,顶部是通常的白色文本,顶部是第二个完全空白的文本。
我把第一行改成如下,把第二行注释掉:
system("cmd /c start echo off" "\n" 命令 "")
--- 这得到了与第二个 dot-point 相似的结果,但只有一个命令 window,黑色(无文字)
如果我不包含“\n”标记,那么我会得到一个 cmd window,其中包含 "off" 命令的文本(其中命令是上面定义的字符串) .
如果我只有 system("cmd /c start " commands "") 行,而不是 echo 行,那么 cmd window 会短暂闪烁并消失,没有进一步的结果演示脚本出现成功。
所以我的问题是:我知道这个脚本在直接通过命令行 运行 时有效,我遇到的问题是我现在无法通过 dxl 运行 它。
运行 echo命令前面没有@的dxl脚本能用吗?
我已经开发出一个可靠的解决方法,它完全符合我的需要。
问题是我用 dxl 编写的输入没有正确通过命令行。
知道来自 cmd 的脚本 运行 正确,反过来,脚本正确地从批处理文件执行,并且我可以 运行 来自 dxl 的批处理文件,我的解决方案是如下:
- 使用格式 C:\PROGRA~1\PATHNAME\
在 dxl 中定义路径
- 使用Stream write()命令直接写入指令
到 .bat 文件
- 然后使用 system() 命令 运行 .bat 文件
我已经包含了一些我的代码,所以它可能会帮助那些试图做同样事情的人。 (我很乐意接受任何关于更好的编程约定的建议。)
// functions used: genFileName(), assume if a variable is not declared here, it was declared under my globals
// genFileName() returns a string of the file name, replacing any " " with "_" so cmd doesn't cry when I run it
string basename = genFileName()
string fcsv = basename ".csv"
string csvPath = "blahblahthefilepath" fcsv
if(fileExists_(csvPath)) isFile = true
Stream fOut = append(csvPath)
// === if file does not exist, create, give column names
if( !isFile){
fOut << "Date and Time,count1,count2,count3,count4" "\n"
}
else ack ("File name exists, append stats to file?" // may not be necessary
// === print to file ===
fOut << datetime "," ctot "," ctc "," cti "," ctnc "\n"
// ===== Create Batch file to run grapher ===
string columnsToPlot = "1 3 1 4 1 5" // ==> may develop this to allow user to choose
string graphDim = "800 600" // ==> px dim, may develop for user choice
string fbat = basename ".bat"
string batPath = "blahblahthefilepath"
Stream batOut = write(batPath fbat)
batOut << "@echo off" "\n"
batOut << "title Batch file to plot statistics for " fcsv "\n"
batOut << "cscript //nologo " batPath "csvplot.vbs " batPath fcsv " " batPath basename ".png " graphDim " " columnsToPlot ""
system("cmd /c start " batPath fbat "")
// some infoBox feedback DB to tell the user that the files were created
祝其他尝试类似事情的人好运,我希望这对某人有用。
我想调用 运行 一个名为 csvplot.vbs (from this site) 的文件来转换我使用 dxl 编写的 .csv 文件(有 5 列,每列都有一个标题和然后只是数值数据)转换成图表(存储为 .png)。
我有 运行 直接通过 cmd 成功执行以下指令:
@echo off
cscript //nologo C:\Users\Administrator\csvplot.vbs C:\PROGRA~1\IBM\Rational\DOORS.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.csv C:\PROGRA~1\IBM\Rational\DOORS.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.png 800 600 1 3 1 4 1 5
pause
这将生成所需的 .png 文件。
然而,我想要的是能够通过 DOORS 执行此操作,以便每当生成原始数据的脚本是 运行 时,它也会生成一个图表。
我的测试用例是这样的:
string echostr = "@echo off"
string commands = "cscript //nologo C:\Users\Administrator\csvplot.vbs C:\PROGRA~1\IBM\Rational\DOORS\9.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.csv C:\PROGRA~1\IBM\Rational\DOORS\9.6\lib\dxl\addins\Verification\Statistics\statGenTest_Top_Level.png 800 600 1 3 1 4 1 5"
system("cmd /c start @echo off") // doesn't recognise echo command
system("cmd /c start " commands "")
我收到一个错误:
"Windows cannot find '@echo'. Make sure you typed the name correctly, and then try again."
我不知道如何通过 dxl 的 cmd 将脚本获取到 运行,如果有任何帮助,我将不胜感激。我之前只通过 dxl 尝试过一次 system() 提示,而且只是为了打开一个 .pdf。与此同时,我会继续努力解决这个问题。如果我可以提供任何进一步的信息,请告诉我。
编辑:更多信息
- @echo: 我删除了 @ 看看它是如何运作的,它带来了一片空白 cmd window 并且不执行进一步的操作。为了甚至运行下面几点的东西,我把@关掉了。
- 我从第二个 system() 行中删除了“/c start”:这会打开一个命令行,顶部是通常的白色文本,顶部是第二个完全空白的文本。
我把第一行改成如下,把第二行注释掉:
system("cmd /c start echo off" "\n" 命令 "")
--- 这得到了与第二个 dot-point 相似的结果,但只有一个命令 window,黑色(无文字)
如果我不包含“\n”标记,那么我会得到一个 cmd window,其中包含 "off" 命令的文本(其中命令是上面定义的字符串) .
如果我只有 system("cmd /c start " commands "") 行,而不是 echo 行,那么 cmd window 会短暂闪烁并消失,没有进一步的结果演示脚本出现成功。
所以我的问题是:我知道这个脚本在直接通过命令行 运行 时有效,我遇到的问题是我现在无法通过 dxl 运行 它。
运行 echo命令前面没有@的dxl脚本能用吗?
我已经开发出一个可靠的解决方法,它完全符合我的需要。
问题是我用 dxl 编写的输入没有正确通过命令行。
知道来自 cmd 的脚本 运行 正确,反过来,脚本正确地从批处理文件执行,并且我可以 运行 来自 dxl 的批处理文件,我的解决方案是如下:
- 使用格式 C:\PROGRA~1\PATHNAME\ 在 dxl 中定义路径
- 使用Stream write()命令直接写入指令 到 .bat 文件
- 然后使用 system() 命令 运行 .bat 文件
我已经包含了一些我的代码,所以它可能会帮助那些试图做同样事情的人。 (我很乐意接受任何关于更好的编程约定的建议。)
// functions used: genFileName(), assume if a variable is not declared here, it was declared under my globals
// genFileName() returns a string of the file name, replacing any " " with "_" so cmd doesn't cry when I run it
string basename = genFileName()
string fcsv = basename ".csv"
string csvPath = "blahblahthefilepath" fcsv
if(fileExists_(csvPath)) isFile = true
Stream fOut = append(csvPath)
// === if file does not exist, create, give column names
if( !isFile){
fOut << "Date and Time,count1,count2,count3,count4" "\n"
}
else ack ("File name exists, append stats to file?" // may not be necessary
// === print to file ===
fOut << datetime "," ctot "," ctc "," cti "," ctnc "\n"
// ===== Create Batch file to run grapher ===
string columnsToPlot = "1 3 1 4 1 5" // ==> may develop this to allow user to choose
string graphDim = "800 600" // ==> px dim, may develop for user choice
string fbat = basename ".bat"
string batPath = "blahblahthefilepath"
Stream batOut = write(batPath fbat)
batOut << "@echo off" "\n"
batOut << "title Batch file to plot statistics for " fcsv "\n"
batOut << "cscript //nologo " batPath "csvplot.vbs " batPath fcsv " " batPath basename ".png " graphDim " " columnsToPlot ""
system("cmd /c start " batPath fbat "")
// some infoBox feedback DB to tell the user that the files were created
祝其他尝试类似事情的人好运,我希望这对某人有用。