Gabe Green wrote:
>
> I'm trying to get a file to copy to all users home directories. When I
> run it as root below, it does not produce any error, but it does not copy
> /etc/sofficerc to .sofficerc in each directory in /home, as I expected.
>
> What am I missing here?
Put the closedir() _outside_ of the loop! You should also check the
return value from symlink().
> #!/usr/bin/perl -w
> # simple script by GG to make sure .sofficerc is in user home directories
> # 9/20/2001
>
> my $dirname = "/home";
> my $name;
> my $symlink = "/etc/sofficerc";
>
> opendir HOME, $dirname or die "Cannot open $dirname: $!";
> while (my $name = readdir HOME) {
> print "$name ";
>
> next if $name =~ /^\./; # skip over dotfiles
> next unless -d $name;
> $name = "$dirname/$name";
>
> symlink $symlink, "$name/.sofficerc";
symlink $symlink, "$name/.sofficerc" or
warn "Cannot link $name/.sofficerc to $symlink\n";
}
closedir HOME;
> closedir HOME;
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]