Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set guid bit on a dir/file within perl

Status
Not open for further replies.

gkmccone

Technical User
Oct 24, 2001
17
US
I am trying to set the guid bit on a bunch of files within a perl script that performs my software install.

I have tried using the Perl chmod with 2755 as the permissions, but this seems to completly confuse chmod as the permission on the dir looks like "d-ws----wt".

I was hoping to avoid shelling out to use the Unix chmod, since it would be a wee bit of overhead.
 
My guess is that you tried:
[tt]chmod '2755', @files;[/tt]

when what you should have tried is:
[tt]chmod 02755, @files;[/tt]

[tt]chmod[/tt] does not like taking a string for the permissions (the reason for this is that 2755 is an octal number, not decimal.) You could do: [tt]chmod oct('2755'), @files;[/tt] as well.
 
Boy do I feel dumb. I knew that using chmod( '2755', @files)
would cause problems, so I was calling it as
chmod( 2755, @files ), but since I didn't have the leading
zero, Perl was interpreting 2755 as a decimal instead of
octal.

Thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top