我想调用运行一个名为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\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
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无法找到' @ echo'。确保正确输入名称, 然后再试一次。"
我对如何让脚本从dxl运行cmd感到茫然,我将不胜感激任何帮助。我之前只有一次涉及system()提示通过dxl,它只是打开一个.pdf。与此同时,我会继续努力解决这个问题。如果我能提供任何进一步的信息,请告诉我。
修改:更多信息
我更改了第一行,如下所示,并注释掉第二行:
系统(" cmd / c启动回声关闭"" \ n"命令"")
---这与第二个点相似,但只有一个cmd窗口,黑色(没有文字一个)
如果我不包含" \ n"然后我得到一个cmd窗口,文本为" off"命令(其中命令是上面定义的字符串)。
如果我只有系统(" cmd / c start"命令"")行,而不是回显线,则cmd窗口会短暂闪烁并且消失,没有进一步的结果证明脚本的成功。
所以我的问题是:我知道这个脚本在直接通过命令行运行时有效,我遇到的问题是我现在无法通过dxl运行它。
答案 0 :(得分:1)
我已经开发了一个可靠的解决方案,完全符合我的需要。
问题是我输入dxl的输入没有正确地通过命令行。
知道脚本正确地从cmd运行,反过来,脚本正确地从批处理文件执行,并且我可以从dxl运行批处理文件,我的解决方案如下:
我已经包含了一些代码,所以也许它可能有助于某些人尝试做同样的事情。 (我很乐意就更好的编程惯例提出任何建议。)
// 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
祝所有尝试类似事物的人好运,我希望这对某人有用。
答案 1 :(得分:0)
在echo命令前面运行没有@的dxl脚本是否有效?