Get quota output from cyradm (cyrus) in a bash script

2.1k views Asked by At

I have am writing a script to list the quota of all the users in my LDAP directory. For this, I use ldapsearch with the appropriate filters to get a list of my usernames in a file. Next I run that file through a while loop which reads the file line-by-line and uses a here document to send the username to the cyrus shell. This is what the loop looks like:

while read userName;do

        cyradm -u cyrus -w my_cyrus_password  localhost << sample
lq user/$userName 
sample

done</home/myuser/tempfiles/tempnames.txt

where lq is the cyradm command to list quota for a user.

I need to output the username and its corresponding quota into a file. How do I do that from within the loop?

1

There are 1 answers

2
SSaikia_JtheRocker On BEST ANSWER

Hope you tried this ->

while read userName;do

echo $(cyradm -u cyrus -w my_cyrus_password localhost << sample
lq user/$userName 
sample
) >> outfile

done</home/myuser/tempfiles/tempnames.txt