Javascript node.js错误:执行命令行命令时生成ENOSYS
我正在尝试在unix下运行node.js,并收到以下错误提示:Javascript node.js错误:执行命令行命令时生成ENOSYS,javascript,unix,node.js,Javascript,Unix,Node.js,我正在尝试在unix下运行node.js,并收到以下错误提示: var exec = require('child_process').exec; var commandLine = "/var/util/generate 300 300 > /tmp/barcode.png"; var childProcess; http.createServer(function (req, res) { var request = url.parse(req.url, true); var a
var exec = require('child_process').exec;
var commandLine = "/var/util/generate 300 300 > /tmp/barcode.png";
var childProcess;
http.createServer(function (req, res) {
var request = url.parse(req.url, true);
var action = request.pathname;
if (action == '/barcode.png') {
console.log('executes commandLine');
// executes 'commandLine'
childProcess = exec(commandLine,
function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr);
var img = fs.readFileSync('/tmp/barcode.png');
res.writeHead(200, {
'Content-Type' : 'image/png'
});
res.end(img, 'binary');
if (error !== null) {
console.log('exec error: ' + error);
}
});
} else {
res.writeHead(200, {
'Content-Type' : 'text/plain'
});
res.end('QR Generate service reply: Please provide correct request parameter \n');
}
}).listen(8888);
log(“QR生成运行于的服务”)
但我得到了:
Error: ENOSYS spawn
at errnoException (child_process.js:476:11)
at ChildProcess.spawn (child_process.js:443:11)
at child_process.js:341:9
at Object.execFile (child_process.js:250:15)
at child_process.js:217:18
at Server.<anonymous> (/base/usr/node/service.js:139:18)
at Server.emit (events.js:70:17)
at HTTPParser.onIncoming (http.js:1479:12)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1375:22)
错误:ENOSYS spawn
在errnoException(child_process.js:476:11)
在ChildProcess.spawn(child_process.js:443:11)
在child_process.js:341:9
在Object.execFile(child_process.js:250:15)
在child_进程中.js:217:18
在服务器上。(/base/usr/node/service.js:139:18)
在Server.emit上(events.js:70:17)
在HTTPParser.onIncoming(http.js:1479:12)
在HTTPParser.onHeadersComplete(http.js:102:31)
在Socket.ondata(http.js:1375:22)
当它击中exec时(
怎么了
节点的版本是0.6.4我的问题没有解决方案,它是在不支持在服务期生成的平台上执行的。我的问题没有解决方案,它是在不支持在服务期生成的平台上执行的。你能成功运行“/var/util/generate 300>/tmp/barcode.png”吗是否在命令行上运行?是的,它可以工作。它可以在/tmp中创建正确的文件您可以在命令行上成功运行“/var/util/generate 300 300>/tmp/barcode.png”?是的,它可以工作。它可以在/tmp中创建正确的文件