Skip to content
Advertisement

Running Perl script accidentally locked a folder

I have a Perl script which has the following code

#/usr/bin/perl
use strict; use warnings;
chmod -R 775,"path-to-current-folder";

Upon running this script, I am unable to access the current folder (and open this script of course) anymore. When seeing the folder in Konqueror, there is an additional lock in the folder icon. Can anyone tell me what happened and how can I undo this?

I have checked the permission of this folder, apparently it was changed to d---------. I have solved this problem by resetting the permission, yet it would be great if anyone could explain why this happened. Thanks.

Advertisement

Answer

I think you’re confusing the ‘chmod’ shell command with the ‘chmod’ perl function. The latter takes a single list as a parameter the first element of which must be the numeric code experessed in octal. From perldoc -f chmod ;

  chmod LIST
           Changes the permissions of a list of files.  The first element
           of the list must be the numeric mode, which should probably be
           an octal number, and which definitely should not be a string of
           octal digits: 0644 is okay, but "0644" is not.  Returns the
           number of files successfully changed.  See also "oct" if all
           you have is a string.

               $cnt = chmod 0755, "foo", "bar";
               chmod 0755, @executables;
           ... etc ...

The former – that is, the shell – has a -R switch. See man chmod for details.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement