gwhite has asked for the wisdom of the Perl Monks concerning the following question:

I have a cross platform CGI application, it does great on *nix systems, but my reporting system is having trouble creating files and directories on Solaris (both v8 and v9). The programs run fine, just no output files and no errors thrown or I get an empty file. The output comes from both my program and a couple of modules (SpreadSheet::WriteExcel for one). But this is pretty simple stuff, for instance:

if (!(-e $newdir)) { mkdir $newdir, 0766 or die "couldn't mkdir $newdir because: $!\n"; chmod (0777, $newdir)or die "couldn't chmod $newdir because: $!\n" +; }
Under *nix this creates my report directory, under Solaris, I get nothing.

Is there anything unique to Solaris in regards to permissions or users that are gotchas that could be causing this?

g_White

Replies are listed 'Best First'.
Re: Solaris IO?
by sweetblood (Prior) on Aug 17, 2004 at 11:43 UTC
    You may want to make sure that $newdir actually contains the directory's name, you can simply print it. Another thing is that while you're trying to create the directory with permissions 766 the next line you change to 777. You could simply
    do { mkdir $newdir, 0777 || die "Yikes!, $!\n" } unless (-e $newdir)

    HTH

    Sweetblood

      Yes, the create and change was one of my debugging efforts, and $newdir does contain the directory, like I mentioned before, this code runs fine on a different platform and I have printed it in the program debug mode. I suspect a minor syntax difference with Solaris or an OS issue with permissions or the user that the web server runs under.

      g_White
        By chance did you try from the command line, creating the directory on Solaris, under the web server user ID? That might reveal something..

Re: Solaris IO?
by neilh (Pilgrim) on Aug 18, 2004 at 01:27 UTC
    G'day, I've just attempted this first on a Debian 3.0 box, and then on a Solaris 9 box. Both work exactly the same (ie create the directory).

    Does the webserver owner have permission to create a directory where $newdir is supposed to be?

    Neil

A reply falls below the community's threshold of quality. You may see it by logging in.