Skip to content

child_process.exec does not run alias or a bash function #3916

@unbalanced

Description

@unbalanced

Hey, i have a bash alias on my ubuntu server

myalias="some unix command here"

When running node:

child_process.exec('myalias', {shell: '/bin/bash'},
        function (error, stdout, stderr) {
            console.log('stdout: ' + stdout);
            console.log('stderr: ' + stderr);
            if (error !== null) {
                console.log('exec error: ' + error);
            }
        });

Result with the following error:

exec error: Error: Command failed: /bin/bash -c myalias

How can i workaround to run alias or bash function in order to shortcut a long command line.
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions