Search code examples
phpibm-midrangeqshell

PHP CLI - Command Ended with Exit Status 2 Troubleshooting


I am trying to run some PHP code from Qshell on an AS/400, and it keeps giving me the following error message: Command ended normally with exit status 2. This has been difficult to test, because it's a dummy user that's running it automatically, and when I run it under my account it works just fine.

According to this guide, this return code is either a missing argument (which I find unlikely, since it works for me) or a permissions issue, but I have checked all of the permissions multiple times and it seems like they're all set properly. I have tried to get a PHP error log, but it doesn't get filled at all, meaning it doesn't even get into the PHP code.

Here's a sample command that I'm running:

/path/php-cli /other_path/myPHP.php "inFile=abc.txt"

Is there any way to find out what file is missing the proper permissions, or is it just an Easter egg hunt?


Solution

  • I found a solution, hopefully this will help someone in the future:

    The PHP-CLI we were using was outdated, so I used the PHP call itself instead (located in /php/bin/php by default). This still gave errors, but the error log I created finally started getting filled, and I was able to pinpoint which file was causing the error.