Re: chmod a file from within a perl file.

by John Erjavec V <jev(at)pconline.com>

 Date:  Fri, 03 Mar 2000 23:06:23 -0600
 To:  "Jan Morell" <janman(at)n-jcenter.com>,
"HWG-Languages" <hwg-languages(at)hwg.org>
 In-Reply-To:  janman
  todo: View Thread, Original
At 06:54 PM 3/3/00 -0500, Jan Morell wrote:
>Here is the code that I am using to create the file in question. Any help
>would be appreciated.
>
>open (RESET_FILE, ">>/path/reset.cgi");
>print RESET_FILE <<"EOT";
>Contents here
>EOT
>close (RESET_FILE);

After creating the file, you would use the chmod function to change the 
file permissions.  From the perl docs (available for reprinting):

=item chmod LIST

Changes the permissions of a list of files.  The first element of the
list must be the numerical mode, which should probably be an octal
number, and which definitely should I<not> a string of octal digits:
C<0644> is okay, C<'0644'> is not.  Returns the number of files
successfully changed.  See also L</oct>, if all you have is a string.

     $cnt = chmod 0755, 'foo', 'bar';
     chmod 0755, @executables;
     $mode = '0644'; chmod $mode, 'foo';      # !!! sets mode to
                                              # --w----r-T
     $mode = '0644'; chmod oct($mode), 'foo'; # this is better
     $mode = 0644;   chmod $mode, 'foo';      # this is best

Hope this helps you out.

-JEV
--
John Erjavec V  ##  spammers-will-be-reported(at)jevonline.com
                 ##  http://www.jevonline.com/jev/index.html
"I'll say it again for the logic impaired."  --Larry Wall

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA