Nodejs exec无法正常工作

时间:2014-09-22 13:36:01

标签: javascript node.js selenium exec dos

我使用exec执行一些DOS命令:

java -jar D:\selenium\selenium-server-standalone-2.40.0.jar -htmlSuite "*firefox3 C:\Users\AppData\Local\Mozilla Firefox\firefox.exe" "http://google.com" "D:\selenium\TS2.html" "D:\selenium\Res3.html"

exec(['java','-jar','D:/selenium/selenium-server-standalone-2.40.0.jar','-htmlSuite','"*firefox3','C:/Users/AppData/Local/Mozilla Firefox/firefox.exe"','"http://google.com"','"D:/selenium/TS2.html"','"D:/selenium/Res3.html"'], function(err, out, code) {

});

将错误显示为

HTML suite exception seen:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect

请帮我执行此命令 提前谢谢:)

1 个答案:

答案 0 :(得分:0)

-htmlSuite参数的值分为两部分。

你可能会在你的路径名(because you're on dos/win)中使用反斜杠:

    exec(['java','-jar','D:\\selenium\\selenium-server-standalone-2.40.0.jar','-htmlSuite','"*firefox3 C:\\Users\\AppData\\Local\\Mozilla Firefox\\firefox.exe"','"http://google.com"','"D:\\selenium\\TS2.html"','"D:\\selenium\\Res3.html"'], function(err, out, code) {

});