|
|
|
|
|
|
| Author |
Message |
Chris F.A. Johnson *nix forums Guru
Joined: 20 Feb 2005
Posts: 2268
|
Posted: Tue Feb 15, 2005 4:18 pm Post subject:
Re: Read one line of a file
|
|
|
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
|
Posted: Tue Feb 15, 2005 3:53 pm Post subject:
Read one line of a file
|
|
|
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 |
|
 |
|
|
The time now is Fri Jan 09, 2009 12:12 am | All times are GMT
|
|
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
|
|