Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Administrators

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-2010, 02:11 AM
Trained Alumni
 
Posts: 28
Default Fast way to get all accounts and aliases?

I need a list of all accounts and aliases for a script I am writing. I have a one-liner that looks like it will deliver the goods but it is incredibly slow (one hour and counting)...
Code:
for i in `zmprov -l gaa`; do echo "$i"; zmprov -l ga $i | grep -i "MailAlias" | sed 's/zimbraMailAlias\: //gi'; done | sort | uniq
When I use the admin web interface I can see lists of accounts and aliases almost instantly. So how does the admin interface do it? I would like to get these lists from the command line at a similar speed. Is this possible?
Reply With Quote
  #2 (permalink)  
Old 06-02-2010, 04:44 AM
Special Member
 
Posts: 113
Default

Quick'n'Dirty and not a one-liner.

Code:
#!/bin/bash

tempfile1="/tmp/zmprov_file1"
tempfile2="/tmp/zmprov_file2"
tempfile3="/tmp/zmprov_file3"

rm $tempfile1 $tempfile2 $tempfile3 2> /dev/null

for i in $(zmprov -l gaa); do 
  echo "ga $i zimbraMailAlias" >> $tempfile1
done 

zmprov < $tempfile1 > $tempfile2

awk '{ print $2 }' $tempfile1 > $tempfile3 
egrep -v '^prov>|^$' $tempfile2 | awk '{ print $2 }' >> $tempfile3
sort -u $tempfile3

rm $tempfile1 $tempfile2 $tempfile3
Need 16 secondes for over 400 accounts. Instead of run zmprov for each account to get the zimbraMailAlias zmprov use the $tempfile1 for command input. Therefore zmprov is only run twice.
Reply With Quote
  #3 (permalink)  
Old 06-02-2010, 04:59 AM
Trained Alumni
 
Posts: 28
Default

Thanks for the speedy and detailed response! I'll give that a try.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.