From: zentara <[EMAIL PROTECTED]>
> I made a little test case to demonstrate the problem.
> The following script is run by root in /home/user:
> /home/zentara/backup-homex
> --------------------------------------------------------------------
--
> ----------------------------- #!/usr/bin/perl -w
> 
> @users=('/home/zentara');
> 
> #put all user-root hidden files and hidden dirs into 1 temp dir
> #this makes it easier to backup second level subdirs
> foreach $homedir(@users){
> opendir DIR, $homedir or warn "Cannot readdir $homedir:$!\n";
> @files = grep !/^\.\.?$/, readdir DIR;
> foreach (@files){push @movem,$_ if -f}
> foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)}
> print "@movem\n";
> print "##############################################\n";
> }
> exit;
> --------------------------------------------------------------------
--
> ------------------------------
> 
> When the above script is run as user or as root in /home/zentara
> the output is good:
> 
> when the above script is run by
> root from /, the output misses some plain files, notably sig, but 
many
> are missing, seemingly random:

Ahh the usual mistake.

The readdir() returns just the file and subdirectory names, not 
complete paths.

Therefore if you opendir() some other directory than '.' you have to 
prepend that directory to the filenames before you do the tests.
Otherwise you are looking at the files in the current directory.

Try
        foreach (@files){push @movem,$_ if -f "$homedir/$_"}

Jenda

===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to