Hello everyone, I am starting to work on a script that is going to process a few files in some users directories. I thought I would do some checking on the file to make sure they are there and to make sure they are really files. I thought it was going to be pretty straight forward, until I ran it for the first time. Sometimes the script sees the file for one user but not the next ( that I know is there)? I must be misunderstanding something small, but I can't figure it out. Can anyone offer any suggestions?
Thanks, Chad ______________________________________________________________________ #!/usr/local/bin/perl eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use warnings; use Sys::Hostname; $|++; use vars qw( $server $pwdfile @users ); $server = hostname(); $pwdfile = '/etc/passwd'; # get users open (PASSWD,"$pwdfile") or die "Cannot open passwd file: $!"; while (my $pwdline = <PASSWD>) { my ($user,$home,$shell) = (split /:/, $pwdline)[0,5,6]; next if ( $home !~ /^\/home/ || $shell !~ /^\/bin/ || $user eq "ftp" || $user eq "www"); push @users, $user; } close (PASSWD); foreach my $user(@users) { print "Starting $user...\n"; #print glob ("/home/$user/*-logs/old/200312/access-log.31-*.gz")."\n"; $user = trim($user); my $decfile = glob ("/home/$user/*-logs/old/200312/access-log.31-*.gz"); my $janfile = glob ("/home/$user/*-logs/old/200401/access-log.01-*.gz"); if (!$decfile) { print "\t\\Could not find Dec 31,2003 access log.\n"; next; } elsif (!-f $decfile) { print "\t\\Dec 31,2003 access log is not a file.\n"; next; } elsif (!$janfile) { print "\t\\Could not find Jan 01,2004 access log.\n"; next; } elsif (!-f $janfile) { print "\t\\Jan 01,2004 access log is not a file.\n"; next; } else { print "\t\\$user has both access logs.\n"; } } # subs sub trim { my @in = @_; for (@in) { s/^\s+//; s/\s+$//; s/\n//g; } return wantarray ? @in : $in[0]; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>