niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
Read one line of a file
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Chris F.A. Johnson
*nix forums Guru


Joined: 20 Feb 2005
Posts: 2268

PostPosted: Tue Feb 15, 2005 4:18 pm    Post subject: Re: Read one line of a file Reply with quote

On Tue, 15 Feb 2005 at 16:53 GMT, Dale DeRemer wrote:
Quote:
I'm updating the passwd file between 2 servers. Now, I need to create and
assign ownership to directories. mkuser is run on server AA. I copy the
passwd, group, and other appropriate files to sever BB. Now user jsmith is
new, and exists with a home directory of /home/jsmith. On sever BB,
directory /home/jsmith doesn't exist.
I've scripted it so I read the differences between the new and old passwd
file, and have the new lines in a file, (newusers.txt). When I awk for the
5th field to create the home directory, that works great. mkdir will handle
the multiple input lines. chown will not take the same type input. What I'd
like to do, is read the file, one line at a time, and assign one value to
newuserid and one value to newuserdir, and then:
mkdir $newuserdir
chown $newuserid $newuserdir

while IFS=: read user p u g n dir s
do
mkdir $dir
chown $user $dir
done < newusers.txt


The usual thing, though, is to mount the same directories on both.

--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2005, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
Back to top
Dale DeRemer
*nix forums beginner


Joined: 22 Feb 2005
Posts: 29

PostPosted: Tue Feb 15, 2005 3:53 pm    Post subject: Read one line of a file Reply with quote

I'm updating the passwd file between 2 servers. Now, I need to create and
assign ownership to directories. mkuser is run on server AA. I copy the
passwd, group, and other appropriate files to sever BB. Now user jsmith is
new, and exists with a home directory of /home/jsmith. On sever BB,
directory /home/jsmith doesn't exist.
I've scripted it so I read the differences between the new and old passwd
file, and have the new lines in a file, (newusers.txt). When I awk for the
5th field to create the home directory, that works great. mkdir will handle
the multiple input lines. chown will not take the same type input. What I'd
like to do, is read the file, one line at a time, and assign one value to
newuserid and one value to newuserdir, and then:
mkdir $newuserdir
chown $newuserid $newuserdir
Any ideas?
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 12:12 am | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Running php file everyday on scheduled time sachin PHP 1 Fri Jul 21, 2006 12:49 pm
No new posts Regarding thesaurus iso file Srikanth modules 0 Fri Jul 21, 2006 10:42 am
No new posts how can i get a file descriptor not used? mars system 0 Fri Jul 21, 2006 7:41 am
No new posts small GTK "Open file" dialog David Siroky Debian 0 Fri Jul 21, 2006 7:30 am
No new posts Trouble Declaring 3D Array in Header File free2klim C++ 1 Fri Jul 21, 2006 4:07 am

Download Anime | Photography | Bankruptcy | Web Advertising | Auction cars
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1756s ][ Queries: 20 (0.1041s) ][ GZIP on - Debug on ]