Archives for : code 127

PHP system, exec, passthru and return code 127

This is a mindnote for myself. If someone else finds it useful, too == profit.

Because of MageFlow development I need to use quite a lot shell commands, for example ping.

Whenever exec, passthru or system returns code 127 check the path of the command. It means that the command cannot be found. It also means that PHP runs the command in such a shell that does not necessarily have PATH set properly and thus the command is not found.


system('ping', $retval);

$retval is 127.

Specify full path to ping command:

system('/bin/ping', $retval);

$retval is 0 or 1 depending if is available or not.