本文介绍了如何使用nodejs运行shell脚本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用 nodeJS 运行一个 shell 脚本文件来执行一组 Cassandra DB 命令.任何人都可以帮我解决这个问题.
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)
推荐答案
您可以使用 执行任何 shell 命令shelljs 模块
const shell = require('shelljs')
shell.exec('./path_to_your_file')
这篇关于如何使用nodejs运行shell脚本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!