exports.callScript = function(script, argv ,options, callback){
    var spawn = require("node-cmd").get;    
    if(typeof(argv) == 'function'){
        callback = argv;
        argv = null;
    }
    if(typeof(options) == 'function'){
        callback = options;
        options = null;
    }
    if(argv){
        for(var i in argv){
            if(i == parseInt(i)){
                script +=' ' + argv[i];
            }
        }
    }    
    spawn(script, function(err, data, stderr){
        var out = [];
        if(err || stderr) return reject(err);
        out.push(data.toString('utf-8'));
        callback(err, out);
    })
};

执行测试java和python命令:

java -jar RunModel.jar henanshangqiu

python parameter_set.py G:/DCLW/SourceCode/heanp/model/zhumadian/data/params-zhumadian.csv conductivity=5e-8 layer_depth=0.1 hamon_coef=0.004 ssr2gw_rate=0.05 gwflow_coef=0.001 gwsink_coef=0.001 ofp_alpha=0.01 ofp_cmp=0.01 chan_alpha=0.01 chan_cmp=0.01 slowcoef_lin=0.0005 pref_flow_den=0 fastcoef_lin=0.1 initial_water_content=0.065 layer_top_depth=0.01

读后请领个红包赞赏下:

node调用cmd命令封装

node调用cmd命令封装

相关文章: