Skip to contentSkip to conversation

help with script

DISCUSSION pacho baratta 6 participants 7 messages Jul 19, 2001 – Jun 10, 2003

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 14 lines · you

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.

Quoted 7 lines

cat txtfile | ./script

is processing only the 1st user, not the others.

any idea to automatize this process?
tnx, pacho

while loop, $1 and shift can also do it.
here is a sample scripts

let us say u user list are in a file called, users. The following will be mail to all users in the list. Save this script, let us says, myscript.

while [ $1 ]
do
mail cat users
shift
done

If I want to use the above scripts to send mail to all users in the file,

./myscripts cat users

pls replace the mail command name with your own scripts name Note:- You must use cat users with backquote ( not single quote )

#2 lore raw
In reply to pacho baratta
Quoted 13 lines · pacho baratta

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.

Quoted 6 lines

cat txtfile | ./script

is processing only the 1st user, not the others.

any idea to automatize this process?
tnx, pacho

Try:

for i in cat txtfile
do

    ./script $i

done

--
Carl

#3 lore raw
In reply to pacho baratta
Quoted 10 lines · pacho baratta

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

Quoted 8 lines

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?

while read user ; do echo $user | ./script ; done < txtfile

Signature · 1 line
Glynn Clements <[email protected]>
#4 lore raw
In reply to pacho baratta

cat txtfile | xargs -n1 ./script

Quoted 18 lines · pacho baratta
Quoted 18 lines

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.

Quoted 7 lines
Quoted 7 lines

any idea to automatize this process?
tnx, pacho

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

End of included message

Signature · 5 lines
+--------------------------+------------------------------+
| Tim Walberg              | [email protected]      |
| 830 Carriage Dr.         | www.mindspring.com/~twalberg |
| Algonquin, IL 60102      |                              |
+--------------------------+------------------------------+
#5 lore raw
In reply to pacho baratta
Quoted 12 lines · pacho baratta

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.

Quoted 6 lines

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

Signature · 4 lines
Stephen Samuel +1(604)876-0426                [email protected]
		   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.
#6 lore raw
In reply to pacho baratta

welle i did use something suggested by César Soler:
while read uid
do ./myscript $uid
done

tnx anybody for hints,
pacho

Il lun, 2003-06-09 alle 08:56, pacho baratta ha scritto:

Quoted 17 lines

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.

Quoted 8 lines

any idea to automatize this process?
tnx, pacho

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html