Category: | Utility Scripts |
Author/Contact Info | /msg [The Mad Hatter] |
Description: | The other day I had a large number of Perl and shell scripts that were not marked executable. They needed to be, but there was a great deal of them scattered all over the place (a source tree directory, to be precise) and I wasn't about to find and chmod them myself. This is the result.
It will check the first line of a file to see if it starts with a shebang (#!), and if it does, will make it executable for the user who owns it. I shell out to the system chmod because it was simpler and quicker to use the symbolic permissions notation (u+x) instead of stat-ing the file, adding the correct value to the octal permissions, and then using Perl's chmod with that modified value. File names to check are specified as arguments. I used the script in combination with find: find . -type f -exec isscript \{\} \; |
#!/usr/bin/perl -w foreach (@ARGV) { open FILE, $_ or die $!; system "chmod", "-v", "u+x", $_ if <FILE> =~ /^#!/; } |
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Find Scripts and Make Executable
by merlyn (Sage) on Apr 22, 2003 at 04:23 UTC | |
by The Mad Hatter (Priest) on Apr 22, 2003 at 04:37 UTC | |
by merlyn (Sage) on Apr 22, 2003 at 14:00 UTC | |
Re: Find Scripts and Make Executable
by artist (Parson) on Apr 22, 2003 at 15:35 UTC | |
by The Mad Hatter (Priest) on Apr 22, 2003 at 15:39 UTC |