1

Error log:

[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] Perl v5.16.0 required--this is only v5.10.1, stopped at index.cgi line 2.
[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] BEGIN failed--compilation aborted at index.cgi line 2.
[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] Premature end of script headers: index.cgi

This is run as the user: 'support' and support runs perlbrew w/ switch set to 5.16.3 as shown below:

# su - support
print() on closed filehandle $fh at /loader/0x1cb94a8/App/perlbrew.pm line 19.
-bash-4.1$ perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux

What do I need to do to ensure Apache executes index.cgi w/ the perl installed by perlbrew?

morissette
  • 1,071
  • 1
  • 8
  • 29

3 Answers3

2

The OS executes the interpreter identified by the shebang (#!) line of the script it was asked to execute (index.cgi). It's just a question of specifying the path to the interpreter you installed using perlbrew there.

Execute which perl (more familiar) or perl -E'say $^X' (more reliable?) to determine the value needed.


Let's do an example.

One on of my machines, I get the following when using my threaded build of 5.18.2. (You'll get something different.)

$ which perl
/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl

$ perl -E'say $^X'
/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl

So I'd use the following as the first line of index.cgi:

#!/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl
ikegami
  • 367,544
  • 15
  • 269
  • 518
2

use a proper perl/bash shebang..

the following would work perfectly

#!/bin/bash
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=/tmp/.perlbrew
export SHELL=/bin/bash #not really needed
unset XTERM_SHELL #not really needed
source ${PERLBREW_ROOT}/etc/bashrc
perlbrew use perl-5.21.9 > /dev/null 2>&1 # you can add your version here... 
eval 'exec perl -x -wS $0 ${1+"$@"}' if 0;
#! -*-perl-*-
# line 10 The above line/string resets the perldebug line-numbering... 
print "The perl interpretter running this code is $^X\n" ; 
print "This is perl version $^V\n" ; 
print "Hello PerlBrew \n" ;
die "This should be line number 14\n"  ; 
print "x\n" ; 

That will result in...

The perl interpretter running this code is /opt/perlbrew/perls/perl-5.21.9/bin/perl5.21.9
This is perl version v5.21.9
Hello PerlBrew 
This should be line number 14

Hope this helps...

G

ghat
  • 21
  • 2
0

Is there a shebang in index.cgi? Which perl does it point to?

I believe the shebang should point to your custom perl not the system perl that you have shown.

Neil H Watson
  • 1,002
  • 1
  • 14
  • 31
  • #!/usr/bin/perl use v5.16; use strict; use warnings; – morissette Jun 17 '14 at 17:21
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – vonbrand Jun 17 '14 at 17:38
  • @vonbrand, The answer is not exactly high quality, but it does answer the question. Take the first paragraph as rhetorical questions. – ikegami Jun 17 '14 at 17:39
  • `#!/usr/bin/perl` is probably your system Perl. Change that to `#!/path/to/perlbrew/perl` – DavidO Jun 17 '14 at 17:44