Skip to Main Content

Infrastructure Software

Announcement

Testing banner

The working directory of a perl cgi script has changed in Solaris 11.4 to "/" !!

2773576Feb 25 2020 — edited Mar 10 2020

For reasons that are too long to explain, I have an application comprising a number of perl scripts that are executed as CGI within Apache.

This is a test script that I run on both Solaris 11.3 / 11.4 and Linux.

#!/usr/bin/env perl

use strict;

use warnings;

print qq(Content-type: text/plain\n\n);

print "hi\n";

use Cwd qw(cwd);

my $dir = cwd;

print "This is the current directory : $dir\n";

print "This is the perl version: $^V\n";

On Solaris 11.3,(SRU 35) results in

-------------------------------------------------

hi

This is the current directory : /var/apache2/2.4/cgi-bin

This is the perl version: v5.12.5

-----------------------------------------------------

On Solaris 11.4 (SRU17) results in

-------------------------------------------------

hi

This is the current directory : /

This is the perl version: v5.22.1

-------------------------------------------------

(For the record, Linux also returns the directory from which the script was executed).

Needless to say, this has broken the application.

Attempts to change the of @INC, using chdir have had limited success and introduce a hard coded dependency that should be avoided (and unnecessary?).

I do not  think it is Perl that is producing this behaviour... but suggestions welcome.

This post has been answered by Alanc-Oracle on Mar 10 2020
Jump to Answer
Comments
Post Details
Added on Feb 25 2020
2 comments
195 views