LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-01-2008, 03:26 PM   #1
gd121462
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Rep: Reputation: 0
creating a log file of users who are missing a file


Hi,

I have created a shell script which searches users home directories based on their group membership and copies a file if it exists to my home directory. I would also like to create a logfile of all the users that do not have the file.
I am a newbie and there is probably a simple solution but I have been unable to find one.
 
Old 12-01-2008, 03:28 PM   #2
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Quote:
Originally Posted by gd121462 View Post
Hi,

I have created a shell script which searches users home directories based on their group membership and copies a file if it exists to my home directory. I would also like to create a logfile of all the users that do not have the file.
I am a newbie and there is probably a simple solution but I have been unable to find one.
Do you think you could share what you have so far?
 
Old 12-02-2008, 03:50 AM   #3
gd121462
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Original Poster
Rep: Reputation: 0
My code so far

awk -F : '$4 =501{print$1}' /etc/passwd | while
read user
do

find /home/*/pickup -iname 'pickup' | xargs -i cp "{}" /home/gd121462/collection

done
 
Old 12-03-2008, 09:15 AM   #4
gd121462
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Anybody got ideas they want to share with me to help resolve my problem. The code that I have so far is it OK? It seems to do what I want except I do not know how to create the logfile with the users names with no file to pick up.
 
Old 12-03-2008, 12:04 PM   #5
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Quote:
Originally Posted by gd121462 View Post
awk -F : '$4 =501{print$1}' /etc/passwd | while
read user
do

find /home/*/pickup -iname 'pickup' | xargs -i cp "{}" /home/gd121462/collection

done
Code:
awk -F : '$4 =501{print$1}' /etc/passwd | while
read user
do 

find /home/*/pickup -iname 'pickup' | xargs -i cp "{}" /home/gd121462/collection

if [ $? -ne 0 ];
then
    echo $user > /some/log/file
fi
done
Something like that should work. If the previous command fails, it will put the user in a the file.
 
Old 12-04-2008, 04:54 AM   #6
gd121462
LQ Newbie
 
Registered: Dec 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Hi O.o,

I have tried using the code for creating the log file substituting the path for the logfile etc and am getting the following error
./testcode: [0: command not found
The files still get copied to the pickup folder though.
If I amend the code with the following

awk -F : '$4 =501{print$1}' /etc/passwd | while
read user
do

find /home/*/pickup -iname 'pickup' | xargs -i cp "{}" /home/gd121462/collection

if [ $? -ne 0 ];
then
echo $user > /some/log/file
fi | (date;echo $user) | xargs >> log
done

I do get a log file but it gives me every user on the system rather then the ones who belong to the group and have no file in the pickup folder
 
  


Reply

Tags
logfile


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating log file RudraB Programming 2 12-13-2007 12:35 AM
creating a log file ttumelty Programming 2 12-13-2005 01:30 PM
Creating the log-file dr_sad Programming 5 04-12-2005 06:01 PM
Creating a Log file nguye103 Linux - Newbie 1 10-21-2004 07:16 PM
Creating a log file in unix?? linux_dejan Programming 3 09-03-2004 11:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration