user2462648
user2462648

Reputation: 53

shell_exec, popen, exec, passthru not working in codeigniter controller

I have a requirement where i need to run a c program from codeigniter controller, the php shell commands are not wokring in the controller but, when the same commands are used from a simple php(without codeigniter) is working fine.

please help...

the command iam using is

$output = shell_exec("./hello"); //hello.c prints hello world.
echo $output;

the path printed using pwd was my home folder path where the C file is present. the same command (shell_exec("./hello");) wont work in codeigniter.

Upvotes: 0

Views: 4609

Answers (1)

Nishant
Nishant

Reputation: 3694

please check that you are giving the correct path to the exec command in the codeigniter. Use below to check the current directory.

exec('pwd');

Also, if it is in the incorrect directory, do provide the complete path.

Check if the c code file is in this directory or not. and change it accordingly if not.

Please provide the exec commands in your question too.

You should provide the absolute path in the exec command.

$output = shell_exec("/absolute/path/to/executable/hello"); //hello.c prints hello world.
echo $output;

Upvotes: 0

Related Questions