From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Samuel Subject: Re: help with script Date: Tue, 10 Jun 2003 12:58:58 -0700 Sender: linux-admin-owner@vger.kernel.org Message-ID: <3EE63882.2050704@bcgreen.com> References: <1055141806.1522.4.camel@alice> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1055141806.1522.4.camel@alice> List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: pacho baratta Cc: linux-admin@vger.kernel.org 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.