Search code examples
node.jsshellcassandra

How to run shell script file using nodejs?


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)

Solution

  • You can execute any shell command using the shelljs module

     const shell = require('shelljs')
    
     shell.exec('./path_to_your_file')