1

Hi I uploded some files to parse which parsed by node js. currently I am running it from terminal as node app.js.

I need to call it from my php model.

I am thinking shell_exec() function will help. I tried like this

shell_exec('http://172.18.18.219/hrms_work/web/uplodedfiles/test/code4goal-resume-parser/app.js');

but it dose not work.

2 Answers 2

4

You're not executing any command, that's why it doesn't work. shell_exec() take exactly what you'd write in a terminal so this should work better shell_exec('node app.js'). But you will also have to cd to the right directory or provide an absolute path to app.js. You're using an url to app.js, I'm not sure node can run a remote file like that.

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

Comments

3
  1. your shell_exec() argument is wrong. Does this argument work in your terminal? Probably not because is a simple link.
  2. Does your file app.js have the correct permissions to run Apache user?

After answering these questions, make sure you enter the correct argument in shell_exec(): absolute path to app.js and the same command you use in terminal I think is node app.js.

something like shell_exec(node /absolute/path/to/app.js);

please let us know ;)

Comments

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.