views:

41

answers:

2

I am trying to run a shell from one of my controllers in a PHP codeigniter applications,

I am trying to run the file /x/sh/xpay4.sh however I just get 127 returned to the screen, I can even use basic commands like ls or pwd can any suggest why this would be, I thought it might be safe_mode when I ini_get('safe_mode') it returns 1

A: 

system() returns only the last line of the shell output. Sounds likt this is "127".

If you need the whole output instead, try:

$output = array();
exec('/x/sh/xpay4.sh', $output);
echo implode("<br>", $output);
JochenJung
+1  A: 

system function is restricted in safe mode.

You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.

http://www.php.net/manual/en/features.safe-mode.functions.php

el.pescado