nodeJS exec does not work for “cd ” shell cmd

后端 未结 3 1837
忘掉有多难
忘掉有多难 2021-02-05 01:04
var sys = require(\'sys\'),
    exec = require(\'child_process\').exec;

exec(\"cd /home/ubuntu/distro\", function(err, stdout, stderr) {
        console.log(\"cd: \" +          


        
3条回答
  •  生来不讨喜
    2021-02-05 02:08

    It is working. But then it is throwing the shell away. Node creates a new shell for each exec.

    Here are options that can help: http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

提交回复
热议问题