Shell command execution with Node.js

60 views
Skip to first unread message

emerb nura

unread,
Dec 10, 2016, 7:22:16 PM12/10/16
to nodejs
Hi,
Im new to Node.js,I want to execute shell commands using Node.js.When I tried a simple command(ipconfig), I got the outout.But I want to execute CLI commands, So in order to do so I need to execute the commands in a particular path .How to set path from script?. I used child_process.exec() for executing shell commands.Kindly share the code to execute the commands in a particular path.  Thanks

Ryan Schmidt

unread,
Dec 16, 2016, 11:21:00 PM12/16/16
to nod...@googlegroups.com

On Dec 10, 2016, at 11:36 AM, emerb nura wrote:

> Im new to Node.js,I want to execute shell commands using Node.js.When I tried a simple command(ipconfig), I got the outout.But I want to execute CLI commands, So in order to do so I need to execute the commands in a particular path .How to set path from script?. I used child_process.exec() for executing shell commands.Kindly share the code to execute the commands in a particular path. Thanks

Use the absolute path to the program, for example /usr/bin/someprogram, or else set the PATH environment variable to the directory in which the program can be found, for example /usr/bin. (If needed, PATH can contain multiple directories, separated by colon (":") characters.)



Zombie Leet

unread,
Dec 17, 2016, 8:07:42 PM12/17/16
to nodejs
this command line script will do it easily https://github.com/zombieleet/bash-repple
Reply all
Reply to author
Forward
0 new messages