* Re: help with script
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
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Win Toe ( Penguin Millennium ) @ 2001-07-19 13:31 UTC (permalink / raw)
To: pacho baratta, linux-admin
At 08:56 AM 6/9/2003 +0200, you 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 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 )
^ permalink raw reply [flat|nested] 7+ messages in thread
* help with script
@ 2003-06-09 6:56 pacho baratta
2001-07-19 13:31 ` Win Toe ( Penguin Millennium )
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pacho baratta @ 2003-06-09 6:56 UTC (permalink / raw)
To: linux-admin
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: help with script
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
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Carl @ 2003-06-09 9:47 UTC (permalink / raw)
To: pacho baratta, linux-admin
At 08:56 09/06/2003 +0200, 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
Try:
for i in `cat txtfile`
do
./script $i
done
--
Carl
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: help with script
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
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Glynn Clements @ 2003-06-09 12:58 UTC (permalink / raw)
To: pacho baratta; +Cc: linux-admin
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?
while read user ; do echo $user | ./script ; done < txtfile
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: help with script
2003-06-09 6:56 help with script pacho baratta
` (2 preceding siblings ...)
2003-06-09 12:58 ` Glynn Clements
@ 2003-06-09 13:03 ` Tim Walberg
2003-06-10 19:58 ` Stephen Samuel
2003-06-10 23:37 ` pacho baratta
5 siblings, 0 replies; 7+ messages in thread
From: Tim Walberg @ 2003-06-09 13:03 UTC (permalink / raw)
To: pacho baratta; +Cc: linux-admin
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
cat txtfile | xargs -n1 ./script
On 06/09/2003 08:56 +0200, 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
>>
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
End of included message
--
+--------------------------+------------------------------+
| Tim Walberg | twalberg@mindspring.com |
| 830 Carriage Dr. | www.mindspring.com/~twalberg |
| Algonquin, IL 60102 | |
+--------------------------+------------------------------+
[-- Attachment #2: Type: application/pgp-signature, Size: 174 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: help with script
2003-06-09 6:56 help with script pacho baratta
` (3 preceding siblings ...)
2003-06-09 13:03 ` Tim Walberg
@ 2003-06-10 19:58 ` Stephen Samuel
2003-06-10 23:37 ` pacho baratta
5 siblings, 0 replies; 7+ messages in thread
From: Stephen Samuel @ 2003-06-10 19:58 UTC (permalink / raw)
To: pacho baratta; +Cc: linux-admin
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: help with script
2003-06-09 6:56 help with script pacho baratta
` (4 preceding siblings ...)
2003-06-10 19:58 ` Stephen Samuel
@ 2003-06-10 23:37 ` pacho baratta
5 siblings, 0 replies; 7+ messages in thread
From: pacho baratta @ 2003-06-10 23:37 UTC (permalink / raw)
To: linux-admin
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:
> 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
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@vger.kernel.org
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-06-10 23:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2003-06-10 23:37 ` pacho baratta
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.