From: Neagle, G. <Gre...@di...> - 2006-03-04 00:06:51
|
As Patrick pointed out to me, it's probably a good idea to call lapply with the -n option - then you don't have to specify a server. As for encoded characters in transcripts like \b, I haven't seen any issues as is. -Greg On Mar 3, 2006, at 3:12 PM, James Reynolds wrote: > Here is my modified version. I changed a bunch. First, I use k-in-k > so I added support for that. Second, I've downgraded to 1.5.0 (my > idea--mainly because I'm about to push out 10.4.5 to my Macs and I > didn't want to push out more problems) and 1.5.0 doesn't have the -u > flag, so I added the ability to specify the location of lapply (I'll > probably put it in a custom location). I am not using the global > radmind conf file either, so I added the ability to specify the server > (else lapply complains). > > My main question was if this command can handle escaped spaces (\b) in > $_: > > system "echo $_ | $lapply -u 022 $radmind_server"; > > I added \" around $_ thinking that might fix it, but I'm not sure. > > system "echo \"$_\" | $lapply -u 022 $radmind_server"; > > Thanks for the script Greg! (I haven't tested it much either btw) > > James > > #!/usr/bin/perl -w > > # fixSymlinks.pl > # by Greg Neagle, gre...@di... > > # - This script attempts to fix broken symlinks created by lapply 1.5.1 > # when run with the default umask option > # > # - No attempt is made to fix symlinks referenced in negative > transcripts > # > # - Symlinks that are referenced in a positive transcript and a > # higher-precedence negative transcript therefore _will_ be modified, > # this could be bad. In my loadsets, I can find no actual occurrences > # of this problem, since the only symlink I have in any negative > transcript > # is this one: > # l /private/etc/localtime > /usr/share/zoneinfo/US/Pacific > # and it doesn't appear in any other transcripts. But the danger is > there. > # > # - A deeper potential problem is transcript entries that _remove_ > symlinks: > # if a transcript creates a symlink, and a higher-precedence transcript > # removes it, we'll have an unwanted symlink hanging around. A > subsequent > # radmind session will remove it, but if this script is run again, it > will > # come back. > # > # - Therefore we need to deal with "- l" lines in the transcripts as > well. > # Unfortunately, we cannot just blindly pass these lines to lapply, > because if > # symlink doesn't exist in the filesystem, lapply will fail and stop > processing > # transcript lines. > # > # So we'll need to feed symlink removal lines to lapply one-by-one and > ignore > # failures. > > use strict; > > my $radmindClientDir = "/var/radmind/client"; > my $commandFile = $radmindClientDir . "/command.K"; > my $symlinkremovet = "/tmp/symlinkremove.T"; > my $radmind_server = "-h radmind.server.com"; > my $lapply = "/usr/local/bin/lapply"; > > #turn off output buffering > $|++; > > chdir "/"; > > processCommandFile ( $commandFile ); > > sub processCommandFile { > my ( $commandFile ) = @_; > print "Processing command $commandFile...\n"; > (open K, $commandFile) or die "Can't open the command file > $commandFile : $!"; > my @file = <K>; > close K; > my $commandFileLine; > foreach $commandFileLine ( @file ) { > chomp $commandFileLine; > if ($commandFileLine =~ /^p/) { > #positive transcript > my @lineItems = split / /, $commandFileLine; > my $transcript = $lineItems[1]; > print "Processing transcript $transcript...\n"; > process_transcript( $transcript ); > } elsif ($commandFileLine =~ /^k/) { > # command file > my @lineItems = split / /, $commandFileLine; > my $command = $lineItems[1]; > processCommandFile ( "$radmindClientDir/$command" ); > } > } > } > > sub process_transcript { > my ( $transcript ) = @_; > # re-create all symlinks in the transcript: > # grep out all lines that begin with l and send them > # to lapply with a 022 umask > print "-----------------------------------------------------\n"; > system "/usr/bin/grep -h \"^l\" \"$radmindClientDir/$transcript\" > | $lapply -u 022 $radmind_server"; > # grab symlink removal lines > system "/usr/bin/grep -h \"^- l\" > \"$radmindClientDir/$transcript\" > $symlinkremovet"; > print "Removing symlinks flagged for removal in $transcript...\n"; > if (open T, $symlinkremovet) { > while (<T>) { > #feed each line one-by-one to lapply > chomp; > system "echo \"$_\" | $lapply -u 022 $radmind_server"; > } > close T; > } > } > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel? > cmd=lnk&kid=110944&bid=241720&dat=121642 > _______________________________________________ > Radmind-devel mailing list > Rad...@li... > https://lists.sourceforge.net/lists/listinfo/radmind-devel |