-2

I am trying to execute shell commands using php. How to execute those commands listed in comments.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • cd "filelocation" and node filename – amara bkrish Jun 25 '15 at 07:12
  • You tried the standard PHP functions that execute shell commands? What was the outcome? – axxis Jun 25 '15 at 07:57
  • Am i right thinking you want to run execute 'php' within your php code? e.g. `php somephp.php` – Ali Jun 25 '15 at 07:58
  • no i am usig node js .to run a file in node we need to move the cmd prompt to that folder location and need to type the command 'node filename'.if i use the native php command it is saying fatal error – amara bkrish Jun 25 '15 at 09:12
  • So first you need to `cd` to that folder and then execute the command? Check this: http://stackoverflow.com/a/7122994/4768218 – axxis Jun 25 '15 at 20:53

2 Answers2

0

Depends on your webservers configuration. I'm using phpseclib to execute shell commands through php but depending on what you need, a simple shell_exec() could be enough.

Sebastian Nette
  • 7,364
  • 2
  • 17
  • 17
0

shell_exec("script.sh");

For more Informations

ciaodarwin
  • 483
  • 3
  • 7
  • 22
  • in shell_exec is able to open file.but not able to execute line node sample js.how to do shell-exec(' node sample');shell exec('cd filepath'); – amara bkrish Jun 25 '15 at 07:21