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 :: next js react image upload 
Javascript :: js select keys from object 
Javascript :: get data from json placeholder 
Javascript :: jquery validate array input not working 
Javascript :: nodejs delete in mysql 
Javascript :: javascript connect metamask 
Javascript :: exploding string with comma using jquery 
Javascript :: useeffect cleanup in reactjs 
Javascript :: how to run and clone react app 
Javascript :: local storage in vanila javascript 
Javascript :: foreach loop in nodejs 
Javascript :: ** javascript Exponentiation 
Javascript :: hello world in javascript 
Javascript :: how to convert an array into single quote strings 
Javascript :: how to send response to client in nodejs using res object 
Javascript :: find max value in javascript 
Javascript :: react history listen get previous location 
Javascript :: process exit code 
Javascript :: axios response.json 
Javascript :: js store regex in variable and combine 
Javascript :: how to disable strict mode on object in javascript 
Javascript :: logical operators in js 
Javascript :: how to export multiple functions react from one file 
Javascript :: jquery datatable rest api 
Javascript :: select the items from selectors in .map reactjs 
Javascript :: jquery remove multiple class 
Javascript :: see vuex values productin 
Javascript :: foreach method javascript 
Javascript :: move element onclick javascript 
Javascript :: jquery dynamic event handling 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =