Wow, so many good suggestions!  And now I see my good friends chargrill and zentara have come to my aid as well ... thanks, guys!

First of all, to answer your questions, pileofrogs, I wrote a script to generate both hello.pl and do_df.pl, in each directory from a specified list.  That way, I'm guaranteed the scripts have the exact same contents.  I saved everything to a file using the script command, and here are the results:

Script started on Sun 19 Feb 2006 11:59:00 AM EST [root@localhost ~]# cat sayhello #!/usr/bin/perl -w use strict; use warnings; use FileHandle; use File::Basename; my @dirs = qw( /root /root/subdir /var /var/www /var/www/html /var/www/html/bugs ); my $iam = basename $0; foreach my $dir (@dirs) { trydir($dir); } sub tryfile { my ($fname, $text) = @_; my $fh = new FileHandle(); open($fh, ">", $fname) or die "$iam: can't write '$fname' ($!)\n" +; print $fh $text; close $fh; (chmod 0777, $fname) or die "$iam: can't chmod '$fname' ($!)\n"; print "Running '$fname' ...\n"; system($fname); print "Running perl '$fname' ...\n"; system("perl $fname"); } sub trydir { my ($dir) = @_; (chdir $dir) or die "$iam: can't change to '$dir' ($!)\n"; print "\e[102m[In directory '$dir']\e[m\n"; tryfile("./hello.pl", "#!/usr/bin/perl -w\nprint \"Hello!\n\";"); tryfile("./do_df.pl", "#!/bin/df"); } [root@localhost ~]# ./sayhello [In directory '/root'] Running './hello.pl' ... Hello! Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / [In directory '/root/subdir'] Running './hello.pl' ... Hello! Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / [In directory '/var'] Running './hello.pl' ... Hello! Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573692 28666048 12% / [In directory '/var/www'] Running './hello.pl' ... Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573696 28666044 12% / [In directory '/var/www/html'] Running './hello.pl' ... Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573696 28666044 12% / [In directory '/var/www/html/bugs'] Running './hello.pl' ... Running perl './hello.pl' ... Hello! Running './do_df.pl' ... Running perl './do_df.pl' ... Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 33994464 3573700 28666040 12% / [root@localhost ~]# mount /dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw) /dev/proc on /proc type proc (rw) /dev/sys on /sys type sysfs (rw) /dev/devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/sda3 on /boot type ext3 (rw) /dev/shm on /dev/shm type tmpfs (rw) /dev/sda2 on /dos type vfat (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) automount(pid2318) on /misc type autofs (rw,fd=4,pgrp=2318,minproto=2, +maxproto=4) automount(pid2349) on /net type autofs (rw,fd=4,pgrp=2349,minproto=2,m +axproto=4) [root@localhost ~]# exit Script done on Sun 19 Feb 2006 11:59:13 AM EST
As you can see, it's only a problem in certain directories; it works as expected in
/root /root/subdir /var
but fails in
/var/www /var/www/html /var/www/html/bugs
Furthermore it does NOT seem to be limited to perl, since, in the directories where perl fails to work, so does df.

chargrill, you brought up an excellent point; it's important to strip the dos \r character from scripts which were copied from a FAT/FAT32/NTFS system.  I've been stung by that before, and it can be very hard to spot the problem.  Clearly that's not the case here, though, since I'm creating the files directly under Linux.

zentara, your suggestion sounds promising, as I *did* select the "most secure" option during installation, which I believe was referring to the use of ACL's.  I'm not very familiar with them, so I'll have to investigate further.  I did include a mount in the script command above, and didn't see anything unusual.  Also, at the suggestion of my manager, I used the LVM for the first time with this installation -- in the past I've always created the individual separate physical partitions.  But that may not be relevant.

Much thanks again everyone for all the terrific ideas ...

Update:  I should also point out that the strange behavior has changed a little; I see from what I wrote previously that it used to work in /var/www/html; this is not longer the case, as it now only works in /var, but not anything subordinate to that.

Update 2:  The problem is solved!  I showed it to my manager this morning, and he immediately knew what it was -- SELinux was imposing security restrictions on the file, depending on where it was being run from.  So zentara, you win the prize for guessing where the problem was.  All that was needed was to disable SELinux with system-config-security-level.


@ARGV=split//,"/:L"; map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"

In reply to Re: Invoking Perl on a script, vs. using shebang by liverpole
in thread Invoking Perl on a script, vs. using shebang by liverpole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.