0

I want to execute any command from php file. I have one nodejs file and when I give command to execute something. it works fine. i.e. abc.js argument this works fine from terminal and execute some task

but, I want to execute same task from php file which runs my command. I tried with exec('filename argument') that does not work. If I give exec(ls -l) that gives me output.

Please let me know your suggestions.

Thanks

2

1 Answer 1

1

I think you have to use the node command to execute the js file try using

exec('/home/bin/node abc.js');

note use full paths like this /usr/bin/node /tmp/tmp.js or c:\nodejs\bin\node c:\proj\app.js

Sign up to request clarification or add additional context in comments.

6 Comments

Ok..Let me check with this
Yes I tried with all. I gave full path of node, js and arguments. but, Its not working. exec('/usr/local/bin/node /path/abc.js argument');
It has to work. Can you try same command is working in command prompt or not?
just execute some node command and check the output like exec('/usr/local/bin/node -v');
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.