Forum Moderators: coopster & phranque

Message Too Old, No Replies

Changing File Permissions in Perl

Looking for exact syntax

         

jgold454

3:09 pm on Oct 28, 2007 (gmt 0)

10+ Year Member



I am looking for the exact syntax for changing file permissions in a PERL script. This is what I have in the script now but it isn't working:

#!/usr/local/bin/perl
chmod 755 filename.pl;
chmod 755 filename2.pl;

Thanks in advance for any input on this..

Jerry

perl_diver

4:24 pm on Oct 28, 2007 (gmt 0)

10+ Year Member



as they say: RTFM

[perldoc.perl.org...]

You need a comma in there.

chmod 0755, file(s);

SeanW

11:56 pm on Oct 28, 2007 (gmt 0)

10+ Year Member



And don't forget the leading 0 either:


[sean@sergeant tmp]$ touch foo
[sean@sergeant tmp]$ ls -l foo
-rw-r--r-- 1 sean users 0 Oct 28 18:54 foo
[sean@sergeant tmp]$ perl -e 'chmod 777, foo'
[sean@sergeant tmp]$ ls -l foo
-r----x--t 1 sean users 0 Oct 28 18:54 foo
[sean@sergeant tmp]$ perl -e 'chmod 0777, foo'
[sean@sergeant tmp]$ ls -l foo
-rwxrwxrwx 1 sean users 0 Oct 28 18:54 foo

Sean