Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP System Call Always Fails

Tags:

shell

php

cmd

(Seemingly) no matter what command I try to run with PHP's system function, the command always does nothing and then fails with exit code 1. For example,

system("echo 'this should definitely work'", $retval);

sets $retval = 1. So does

system("dir", $retval);

as well as running an executable that I've written; when I run

vfmt -h cat.v

from cmd.exe the command works and returns with exit code 0, but running

system("vfmt -h cat.v", $retval);

again sets $retval = 1. This vfmt.exe file is in the same directory as the src.php script that is attempting these system calls.

I am nearly at my wit's end trying to figure out what's wrong. What could possibly be causing this issue?

like image 672
feralin Avatar asked Apr 08 '26 07:04

feralin


1 Answers

You should check your php.ini for line like the next:

disable_functions =exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
                   ^^^^          ^^^^^^^^^^^^^^^^^^

and such.

Also check your "safe mode" status, (php ver. < 5.4) if you have enabled it you can only execute files within the safe_mode_exec_dir and so on...

More information in the doc and for the execution of commands here and especially for system here.

like image 197
jm666 Avatar answered Apr 10 '26 22:04

jm666



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!