Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

exec in node js

const { exec } = require('child_process');
const cmd = 'scp username@remoteip:remote_location_file /location/where/you/save'
const yourscript = exec(cmd,
        (error, stdout, stderr) => {

            if (error !== null) {
                console.log(`exec error: ${error}`);
            }
            else if(stderr!==null){
                console.log(`exec stderr :${stderr}`);
            }else{
                console.log(stdout.toString());
                console.log("Success !!");
            }
        });
console.log(yourscript)
 
PREVIOUS NEXT
Tagged: #exec #node #js
ADD COMMENT
Topic
Name
9+3 =