如何使用Node.js运行Shell脚本文件? [英] How to run shell script file using nodejs?
本文介绍了如何使用Node.js运行Shell脚本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用执行一组Cassandra DB命令的nodeJS运行Shell脚本文件.有人可以帮我吗?
I need to run a shell script file using nodeJS that executes a set of Cassandra DB commands. Can anybody please help me on this.
内部db.sh文件:
create keyspace dummy with replication = {'class':'SimpleStrategy','replication_factor':3}
create table dummy (userhandle text, email text primary key , name text,profilepic)
推荐答案
您可以使用 shelljs模块
const shell = require('shelljs')
shell.exec('./path_to_your_file')
这篇关于如何使用Node.js运行Shell脚本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文