0

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

3
  • 4
    Does your PHP user have the permissions to execute xpay4.sh? Commented Jul 2, 2010 at 11:51
  • how do I find out my PHP user? Commented Jul 2, 2010 at 11:57
  • 1
    whoami tells who you are (as user), then to check permission I think ls -l could give you the answer about permissions. Commented Jul 2, 2010 at 12:04

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.