linux execute shell script code example
Example 1: node execute shell commands
const { exec } = require("child_process");
exec("cat index.js", (error, data, getter) => {
if(error){
console.log("error",error.message);
return;
}
if(getter){
console.log("data",data);
return;
}
console.log("data",data);
});
Example 2: how to run shell script
chmod +x <fileName>
./fileName.
Example 3: how to run shell script
include
to run
./yourfile.sh
if you do not include that line
bash yourfile.sh
Example 4: how to run shell script
chmod +x <filename>
./<filename>
sh <filename>.sh
bash <filename>.sh
Example 5: how to execute .sh file in linux
./script-name-here.sh