进程失败,退出代码为 1
process failed with exit code 1
我正在尝试 运行 "nightmare" 脚本,使用以下代码进行屏幕截图:
"usr.dir" 包含直到“\src\....”的路径
String root = System.getProperty("usr.dir");
String screenshotJS = "node " + root + "\src\main\resources\screenshot.js";
try {
File tempFile = File.createTempFile(root, ".png");
Process p = Runtime.getRuntime().exec(screenshotJS + " " + url + " " + tempFile.toString());
p.waitFor();
int exitCode = p.exitValue();
if (exitCode != 0) {
System.out.println("Error Execute when exitCode=1");
}else{
System.out.println("Fine Execute when exitCode=0");
}
BufferedImage bufferedImage = new BufferedImage(
500, 500, BufferedImage.TYPE_INT_RGB );
File outputfile = new File(tempFile.getName());
ImageIO.write(bufferedImage, "png", outputfile);
return tempFile.getName();
噩梦剧本:
const nightmare = require('nightmare')();
nightmare
.goto(process.argv[2])
.viewport(1152, 864)
.screenshot(process.argv[3] || 'screenshot.png')
.end(() => {});
进程的return值为1。
我做错了什么?有人可以帮我处理这个案子吗?
谢谢,
伊多
我 运行 npm i nightmare
后问题解决了
我正在尝试 运行 "nightmare" 脚本,使用以下代码进行屏幕截图: "usr.dir" 包含直到“\src\....”的路径
String root = System.getProperty("usr.dir");
String screenshotJS = "node " + root + "\src\main\resources\screenshot.js";
try {
File tempFile = File.createTempFile(root, ".png");
Process p = Runtime.getRuntime().exec(screenshotJS + " " + url + " " + tempFile.toString());
p.waitFor();
int exitCode = p.exitValue();
if (exitCode != 0) {
System.out.println("Error Execute when exitCode=1");
}else{
System.out.println("Fine Execute when exitCode=0");
}
BufferedImage bufferedImage = new BufferedImage(
500, 500, BufferedImage.TYPE_INT_RGB );
File outputfile = new File(tempFile.getName());
ImageIO.write(bufferedImage, "png", outputfile);
return tempFile.getName();
噩梦剧本:
const nightmare = require('nightmare')();
nightmare
.goto(process.argv[2])
.viewport(1152, 864)
.screenshot(process.argv[3] || 'screenshot.png')
.end(() => {});
进程的return值为1。 我做错了什么?有人可以帮我处理这个案子吗?
谢谢,
伊多
我 运行 npm i nightmare