|
Last change
on this file since 724 was
724,
checked in by price, 18 years ago
|
|
parallel-find.pl: work on Macs, and handle errors better
* in find, use -print and a redirect rather than -fprint, which doesn't
exist in the Mac's find
* give a real error message when the directory exists, and die when we should
|
-
Property svn:executable set to
*
|
|
File size:
1016 bytes
|
| Rev | Line | |
|---|
| [722] | 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | # Script to help generate find the .scripts-version files |
|---|
| 4 | |
|---|
| 5 | use lib '/mit/scripts/sec-tools/perl'; |
|---|
| 6 | |
|---|
| 7 | open(FILE, "</mit/scripts/sec-tools/store/scriptslist"); |
|---|
| 8 | my $dump = "/mit/scripts/sec-tools/store/versions"; |
|---|
| 9 | |
|---|
| [724] | 10 | (! -e $dump) || die "Output directory exists: $dump"; |
|---|
| 11 | system("mkdir", $dump) && die; |
|---|
| [722] | 12 | |
|---|
| 13 | use Proc::Queue size => 40, debug => 0; |
|---|
| 14 | use POSIX ":sys_wait_h"; # imports WNOHANG |
|---|
| 15 | |
|---|
| 16 | # this loop creates new childs, but Proc::Queue makes it wait every |
|---|
| 17 | # time the limit (50) is reached until enough childs exit |
|---|
| 18 | |
|---|
| 19 | # Note that we miss things where one volume is inside another if we |
|---|
| 20 | # use -xdev. May miss libraries stuff. |
|---|
| 21 | |
|---|
| 22 | while (<FILE>) { |
|---|
| 23 | my ($user, $homedir) = /^([^ ]*) (.*)$/; |
|---|
| 24 | my $f=fork; |
|---|
| 25 | if(defined ($f) and $f==0) { |
|---|
| 26 | print "$user\n"; |
|---|
| [724] | 27 | my $ret = system("find $homedir/web_scripts -xdev -name .scripts-version -print > $dump/$user 2> /dev/null"); |
|---|
| [722] | 28 | sleep rand 1; |
|---|
| [724] | 29 | exit($ret); |
|---|
| [722] | 30 | } |
|---|
| [724] | 31 | while (waitpid(-1, WNOHANG)>0) { |
|---|
| 32 | $? && die "child exited with error: $?"; |
|---|
| 33 | }; # reaps childs |
|---|
| [722] | 34 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.