Question

I have a strange problem with a php exec() command.

I'm trying to run a perticular gem called iron worker .

exec('iron_worker upload Renode 2>&1',$output,$error);
var_dump($output); 

This is the command i am trying to run, but unfornunately it doesn't upload the code to the service, it only displays

 ------> Creating client

On the contrary, when i run the command with SSH, it works fine, the file is found and the code is uploaded.

If i do a print_r($output); http://pastebin.com/4SLDqQyX

What could be the problem ? The php exec command only stops at the beggining and doesn't continue.

Thank you !

Was it helpful?

Solution

By analysis of the iron_worker source, it looks to use the HOME variable environment and is blocking where no HOME env variable is set.

I suggest you to set the variable with putenv("HOME=/home/my_user/"); before running the script by PHP.

OTHER TIPS

This program seems to need a HOME directory to run from. You have to add this to sudoers file (where http is the webserver and foo is a user on the machine):

http ALL=(foo) NOPASSWD: /path/to/program/or/script

Oh i forgot the system() part..

system("sudo -u foo /path/to/program/or/script");

I would suggest to put the program in /home/foo/. I hope this works for you :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top