SPUG: finding the permissions
Douglas Kirkland
douglas at slugstone.net
Fri Feb 1 22:45:35 CST 2002
Thank for the information.
When I normally copy a file the permissiom of the file get copied also. I
did not think it would be any different in perl. I was wrong.
I was able to get the information I needed from below. I just not see that
the mode contain the file permissions. When I converted the mode to octal
then I saw the permission. I happening to be writting a script that copies
many file to another location with different permission. The permissions
need to match with the orginal file. I was not seeing how in the world to
get the file permissioms from a file. Here is what I needed.
($file_mode) = ( 07777 & (stat($file))[2]);
copy($file,$file2);
chmod( $file_mode, $file2);
Thanks everyone,
Douglas
>
> (stat(FH))[2] will have the information about the mode (type &
> permissions) of the file.
>
> @info = stat("foo.txt");
> printf("%04o\n", $info[2] & 0777);
>
> This will print the mode (for instance 0664)
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list