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
inside db.sh file.
create keyspace dummy with replication = {'class':'SimpleStrategy','replication_factor':3}
create table dummy (userhandle text, email text primary key , name text,profilepic)
You could use "child process" module of nodejs to execute any shell commands or scripts with in nodejs. Let me show you with an example, I am running a shell script(hi.sh) with in nodejs.
hi.sh
node_program.js
Here, when I run the nodejs file, it will execute the shell file and the output would be:
Run
output
You can execute any script just by mentioning the shell command or shell script in
exec
callback.Hope this helps! Happy coding :)
you can go:
just make sure to add shebang in bash script.
You can execute any shell command using the shelljs module