Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

execute bash program using js

function exec(cmd, handler = function(error, stdout, stderr){console.log(stdout);if(error !== null){console.log(stderr)}})
{
    const childfork = require('child_process');
    return childfork.exec(cmd, handler);
}
exec('echo test');
Comment

how to run a bash script with node js

const exec = require('child_process').exec, child;
const myShellScript = exec('sh doSomething.sh /myDir');
myShellScript.stdout.on('data', (data)=>{
    console.log(data); 
    // do whatever you want here with data
});
myShellScript.stderr.on('data', (data)=>{
    console.error(data);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to comment in a json file 
Javascript :: javascript is radio button checked 
Javascript :: javascript reset span html 
Javascript :: shuffle array item javascruitp 
Javascript :: scss next js 
Javascript :: two sum javascript solution 
Javascript :: refresh page by hand in react 
Javascript :: js arithmetic operators 
Javascript :: responsive calc height react native 
Javascript :: Easy Way to Check if 2 Arrays are Equal in JavaScript 
Javascript :: javascript next month from date 
Javascript :: jsonobject in variable 
Javascript :: square node js 
Javascript :: Group array of strings by first letter 
Javascript :: change port react app 
Javascript :: set timeout for loop 
Javascript :: javascript get phone number from string 
Javascript :: ternaire js 
Javascript :: object json parse javascript 
Javascript :: binarycent login 
Javascript :: add numbers in array 
Javascript :: js test if array 
Javascript :: webpack env argument 
Javascript :: export all javascript 
Javascript :: node javascript foreach limit 
Javascript :: check how many files in a folder js 
Javascript :: textalignvertical not working in ios react native 
Javascript :: print all days names of a month js javascript 
Javascript :: javascript string remove substring 
Javascript :: change value of variable javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =