Illegal Command Error Code 127 in PHP Exec Function

illegal command error code 127 in php exec function

Try using the direct path of the application (/usr/bin/unrar of whatever), it sounds like php can't find the application.

Exec command returns 127 error code

The problem is that the maximum length of a command line is 65535 bytes. I don't know why your command line test worked, maybe you've tried it with short filenames but one full command cannot exceed this limit.

The reason I found your question is because I was calling a command line with a heredoc as standard input, and well, the length of a heredoc can easily run away so I rewrote the call using popen() but that doesn't help you. I haven't worked with the zip utility yet, but a quick look at it's manpage says it appends files to existing archives so you should be able to split your command lines after every 64k if you want max efficiency, or after every 100 or even every single file if you want a simple algorithm.

PHP system, exec, passthru return code 127

You need to supply the full path to the binary you want to use. The reason that pdftk would work from command line is that it is in your enviorment $PATH variable (at least if bash, something like that for other shells).

Return code 127 is command not found, so instead of

'pdftk %s fill_form %s output %s %s'

do

'/snap/bin/pdftk %s fill_form %s output %s %s'

Error code 127 returned when using exec() to run PhantomJS

I'm not sure if it's simply a permissions error or what, but after further discussion with @Athafoud I've decided to not use npm to install the phantom and instead just download the binary from their site. This works just fine for whatever reason.

127 Return code from $?

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.



Related Topics



Leave a reply



Submit