【问题标题】:How to run external program(exe, bat) withing casperjs script如何使用 casperjs 脚本运行外部程序(exe、bat)
【发布时间】:2019-04-17 19:11:58
【问题描述】:

我正在运行 casperjs 程序,我希望在脚本期间等待几秒钟并运行 exe 文件。它也可以是 .bat。然后从文本文件中读取结果。据我所知,我现在唯一的问题是从 caseper 程序执行外部 exe。我注意到有一个带有子进程的 shell 解决方案,但是如何在 Windows 上做到这一点?

【问题讨论】:

    标签: javascript phantomjs casperjs


    【解决方案1】:

    找到它!也许它会帮助某人......

    var exec = require('child_process').execFile;
        var test = function(){
               console.log("test is running");
               exec('huh.exe', function(err, ans)
                    {
                        console.log(err)
                    console.log(ans.toString());
                    });  
        }
    test();
    

    【讨论】:

    • 哦,这只是我写评论时的代码,我以为您只是展示了您尝试过的内容,现在我知道这是您上次编辑后的实际答案。对此感到抱歉
    猜你喜欢
    • 2021-09-19
    • 1970-01-01
    • 2010-11-03
    • 2021-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 2017-10-15
    相关资源
    最近更新 更多