From: Stephen Samuel <samuel@bcgreen.com>
To: pacho baratta <pachox@evolinux.it>
Cc: linux-admin@vger.kernel.org
Subject: Re: help with script
Date: Tue, 10 Jun 2003 12:58:58 -0700 [thread overview]
Message-ID: <3EE63882.2050704@bcgreen.com> (raw)
In-Reply-To: <1055141806.1522.4.camel@alice>
pacho baratta wrote:
> i have a txt file with a list of username one by line, say:
> user1
> user2
> user3
> .....
>
> i'd like to avoid to insert all these users by hand (about 1000 users)
> so i build a script to add users, make dirs and something useful to me
>
> my goal is to get a way to process txt file and send all users, one by
> one, to my script.
>
> cat txtfile | ./script
>
> is processing only the 1st user, not the others.
>
> any idea to automatize this process?
> tnx, pacho
while read user ; do
useradd -m $user
do_whatever_else $user
done
This presumes that this is a script you execute as `script < txtfile`
If you were doing it as a one-liner, then the last line would be
`done < txtfile`
Note that the < textfile would have to be after the done construct on
the while loop. if you did: `while read user < txtfile`, the read
command would open txtfile, and read the first line .... over and over
and over again (is this what you're seeing?)
`useradd -m $user` should create the user and their home directory --
normally, in /home/$user , but you can change that with
`useradd -m -d /some/path/$user $user `
--
Stephen Samuel +1(604)876-0426 samuel@bcgreen.com
http://www.bcgreen.com/~samuel/
Powerful committed communication, reaching through fear, uncertainty and
doubt to touch the jewel within each person and bring it to life.
next prev parent reply other threads:[~2003-06-10 19:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-09 6:56 help with script pacho baratta
2001-07-19 13:31 ` Win Toe ( Penguin Millennium )
2003-06-09 9:47 ` Carl
2003-06-09 12:58 ` Glynn Clements
2003-06-09 13:03 ` Tim Walberg
2003-06-10 19:58 ` Stephen Samuel [this message]
2003-06-10 23:37 ` pacho baratta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EE63882.2050704@bcgreen.com \
--to=samuel@bcgreen.com \
--cc=linux-admin@vger.kernel.org \
--cc=pachox@evolinux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).