G
G
gerrrper2014-10-02 13:43:51
bash
gerrrper, 2014-10-02 13:43:51

How to properly run bash script from nodejs (Problem with cd transitions)?

There is bash, for example

cd ../myapp
runmycmd param1 param2
cd dir1/dir2
...
cd ../path

If you run from the console - everything is ok. If I run it from a nodejs script, I get
cd: myapp: No such file or directory

I run it like this:
child = exec("/bin/bash " + 'bash.sh params',
    function (error, stdout, stderr) {
        ...
    }
);

What is missing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2014-10-02
@gerrrper

Specify the full path, not the relative path:

cd /home/user/myapp
...

J
jcmvbkbc, 2014-10-02
@jcmvbkbc

cd ../myapp
What's missing?

Knowing which directory is the current one?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question