cygwin下的phantomjs子进程执行
我试图在cygwin环境下从casperjs脚本调用shell脚本。如果我使用ls、pwd、find等系统命令,下面的代码将打印输出。。。。但当我在execFile函数中指定custom.sh脚本时,它不会打印任何内容。看起来execFile不会触发shell脚本cygwin下的phantomjs子进程执行,cygwin,phantomjs,casperjs,Cygwin,Phantomjs,Casperjs,我试图在cygwin环境下从casperjs脚本调用shell脚本。如果我使用ls、pwd、find等系统命令,下面的代码将打印输出。。。。但当我在execFile函数中指定custom.sh脚本时,它不会打印任何内容。看起来execFile不会触发shell脚本 var casper = require('casper').create({ verbose: true, logLevel: 'debug', }); var cp = require('child_pro
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
});
var cp = require('child_process');
casper.start();
casper.then(function(){
cp.execFile('custom.sh', 'arg', {}, function (err, stdout, stderr) {
console.log("execFileSTDOUT:", JSON.stringify(stdout));
console.log("execFileSTDERR:", JSON.stringify(stderr));
});
casper.waitFor(function check () {
return false;
}, function then() {
console.log('Success').exit();
}, function timeout() {
this.echo("Timeout!!!").exit();
}, 3000)
});
casper.run();
custom.sh:
如果直接从命令行运行custom.sh,则会打印输出:
$ custom.sh
some message
code
但casper日志中没有任何内容:
$ casperjs test.js
[info] [phantom] Starting...
[info] [phantom] Running suite: 1 step
[debug] [phantom] Successfully injected Casper client-side utilities
execFileSTDOUT: ""
execFileSTDERR: ""
[info] [phantom] Step anonymous 1/1: done in 38ms.
[info] [phantom] Step _step 2/2: done in 50ms.
我试图将custom.sh放在/usr/bin中并指定绝对路径,但没有成功
编辑:
有一点要提
cp.execFile'/usr/bin/ls','/'-不返回任何内容
cp.execFile'ls','/'-输出文件列表问题似乎与cygwin路径参数有关 最后,下面的函数调用按预期工作:
cp.execFile('sh', 'custom.sh' ...
你试过使用cp.execFile'sh custom.sh',…?我试过cp.execFile'/usr/bin/sh',custom.sh',。。。
cp.execFile('sh', 'custom.sh' ...