in reply to Perl on M2 Mac issues: somewhere between Perl, Apache and ImageMagick my code fails

I do not know much about apache, this is on the perl side of your problem.

my $result = `$command`; ... executed  as  a system  command,  via /bin/sh or its equivalent if required. see qx/STRING/

So, additionally to checking 1) if the convert binary is indeed installed in said location, 2) if apache is allowed to execute arbitrary binaries from arbitrary filesystem locations, 3) if the current apache user is allowed to do the above for the specific binary, you must also check if apache is also allowed to spawn a shell (and knows where to find its binary).

In order to debug this, I would use Perl's system command passing the command as an array in order to run the convert binary without spawning an intermediate shell, e.g.:

my @command = ( "/opt/local/bin/convert", "foo.jpg". "-crop", "${w}x$h+$x+$x", "./cropped/foo.jpg" ); my $ret = system(@command);

Make sure you check $ret to be zero for successful execution, otherwise check system on how to decipher the return code.

Also, I would try a different, simple binary, check its permissions, move the binary in the current directory where you make sure the apache user has permissions, etc.

Also, please have a look at The problem of "the" default shell and the comments therein which provide system()/qx/`` alternatives (for example: Re: The problem of "the" default shell).

p.s. There may be apache or system logs to explain what happened.

EDIT: Question: where is that exit code (6) documented?

bw, bliako

  • Comment on Re: Perl on M2 Mac issues: somewhere between Perl, Apache and ImageMagick my code fails
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Perl on M2 Mac issues: somewhere between Perl, Apache and ImageMagick my code fails
by choroba (Cardinal) on Oct 24, 2024 at 08:40 UTC
    Also note that qx{} doesn't return an exit code (you can find it in $? instead), but the standard output of the command. So, for some reason, convert outputs 6.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      very useful, convert does run then

Re^2: Perl on M2 Mac issues: somewhere between Perl, Apache and ImageMagick my code fails
by LittleJack (Beadle) on Oct 25, 2024 at 01:04 UTC

    Sorry I should have confirmed that the convert command is absolutely correct, it runs successfully from the command line, and the CGI script runs successfully from the command line.

    I got the interpretation of return code 6 from here: here where it says it's ENXIO 6 No such device or address but that may be the wrong information.