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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-01-2008, 02:26 PM
|
#1
|
LQ Newbie
Registered: Dec 2008
Posts: 4
Rep:
|
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.
|
|
|
12-01-2008, 02:28 PM
|
#2
|
Member
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208
Rep:
|
Quote:
Originally Posted by gd121462
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?
|
|
|
12-02-2008, 02:50 AM
|
#3
|
LQ Newbie
Registered: Dec 2008
Posts: 4
Original Poster
Rep:
|
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
|
|
|
12-03-2008, 08:15 AM
|
#4
|
LQ Newbie
Registered: Dec 2008
Posts: 4
Original Poster
Rep:
|
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.
|
|
|
12-03-2008, 11:04 AM
|
#5
|
Member
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208
Rep:
|
Quote:
Originally Posted by gd121462
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.
|
|
|
12-04-2008, 03:54 AM
|
#6
|
LQ Newbie
Registered: Dec 2008
Posts: 4
Original Poster
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 04:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|