sea_1987
sea_1987

Reputation: 2954

PHP system() help no simple commands work

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

Upvotes: 0

Views: 156

Answers (2)

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

Upvotes: 1

JochenJung
JochenJung

Reputation: 7213

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);

Upvotes: 0

Related Questions