Hi Giuseppe,

I'm not sure about your question, but I'll give it a stab. If I've not
answered to your satisfaction let me know.

You could also do it this way with an array:

<bash script add_users.sh>
#!/bin/sh
domain=mydomain.com
users=(user1 user2 user3 user4)
for index in ${!users[*]}
do
      /home/vpopmail/bin/vadduser -q NOQUOTA ${users[$index]}@$mydomain
psswd_${users[$index]}
      if [ "$?" != "0" ]; then
          echo "Error adding ${users[$index]}@$mydomain"
      else
          echo "Added ${users[$index]}@$mydomain"
      fi
done
</bash script add_users.sh>

Or an array in a separate text file...

<bash script add_users.sh>
#!/bin/sh
domain=mydomain.com
. /path/to/users.txt
for index in ${!users[*]}
do
      /home/vpopmail/bin/vadduser -q NOQUOTA ${users[$index]}@$mydomain
psswd_${users[$index]}
      if [ "$?" != "0" ]; then
          echo "Error adding ${users[$index]}@$mydomain"
      else
          echo "Added ${users[$index]}@$mydomain"
      fi
done
</bash script add_users.sh>

<users.txt>
users=(user1 user2 user3 user4)
</users.txt>

Hope this helps, and of course, you would need to test these scripts first.

Eric

On 3/26/2015 2:09 PM, Giuseppe Perna wrote:
> Eric thanks for the reply,
> but in your script where I post the list of mailboxes to be created?
> I can recall a file.txt?
> thank you
>
>
> 2015-03-26 14:13 GMT+01:00 Eric Broch <[email protected]>:
>> Here's an example:
>>
>> <begin>
>> #!/bin/bash
>> #
>> # Script to add email users to domain
>> #
>> mydomain=testdomain.com
>> while :
>> do
>>    username=""
>>    read -p "Type user to add $mydomain account [CR] exits" username
>>    if [ "$username" = "" ]; then
>>       break
>>    fi
>>    echo ""
>>    echo "Adding $username@$mydomain"
>>    /home/vpopmail/bin/vadduser -q NOQUOTA $username@$mydomain
>> psswd_$username
>>    /home/vpopmail/bin/vuserinfo -a $username@$mydomain
>> done
>> exit 0
>>
>> </begin>
>>
>>
>> On 3/26/2015 6:47 AM, Bharath Chari wrote:
>>
>>
>>
>> On 03/26/2015 02:36 PM, Giuseppe Perna wrote:
>>
>> thanks for the reply,
>>
>> please could you be more specific? are not very experienced.
>> thank you
>>
>> You could do this:
>> create a text file (users.txt) with the information as follows:
>> [email protected] password
>> [email protected] password2
>> [email protected] password3
>> .....
>>
>> Then
>>
>> cat users.txt | '{print "vadduser " $0 }' | sh
>>
>> PLEASE TRY THIS WITH A SINGLE USER FIRST. I don't have a QMT box any more,
>> so I can't try it myself.
>>
>> Bharath
>>
>> 2015-03-26 13:21 GMT+01:00 Johannes Weberhofer <[email protected]>:
>>
>> Am 26.03.2015 um 12:25 schrieb Giuseppe Perna:
>>
>> Hello everyone,
>> I have this configuration qmailtoaser.
>> I have to create 30 of mailboxes in the same domain.
>> there is a procedure for the automatic creation of a single command or
>> scripted?
>>
>> Thank You
>>
>> The simples would be a bash script:
>>
>> for MB in box1 box2 ; do echo vadduser [email protected] ; done
>>
>> You can also set parameters for password generation and things like that.
>>
>> Best regards
>>
>> --
>> Johannes Weberhofer
>> Weberhofer GmbH, Austria, Vienna
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>> --
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to