Discussion:
running cyradm commands from a script
Jessi Berkelhammer
2007-10-12 22:35:35 UTC
Permalink
Hello.

In order to automate some processes, I was hoping to run cyradm from a
script. The O'Reilly "Managing IMAP" book specifies how cyradm can
evaluate Tcl commands, by passing the 'file' option to cyradm. Old man
pages for cyradm online also show the option to pass a file parameter.
However, that isn't an option for 2.3.8, which we are running. Is there
a way to do this, or something similar, with 2.3.8?

Another option could be to have a script call cyradm with a list of
commands to run, like:
cyradm localhost < file_containing_cyradm_commands

However, this is interactive & requires a password; is there a way to
get around this so I can pass the cyradm commands directly from a script?

Thank you,
Jessi B.
Downtown Emergency Service Center
Michael Menge
2007-10-13 18:48:45 UTC
Permalink
Hi,

with Cyradm is writen in perl and cyrus comes a perl packet you can use
to do all things you do with cyradm with perl.
Have a lock at cyrus-imapd-2.3.8/perl/imap

perldoc Cyrus::IMAP # imclient library
perldoc Cyrus::IMAP::Admin # administrative library
perldoc Cyrus::IMAP::Shell # cyradm shell
Post by Jessi Berkelhammer
Hello.
In order to automate some processes, I was hoping to run cyradm from a
script. The O'Reilly "Managing IMAP" book specifies how cyradm can
evaluate Tcl commands, by passing the 'file' option to cyradm. Old man
pages for cyradm online also show the option to pass a file parameter.
However, that isn't an option for 2.3.8, which we are running. Is there
a way to do this, or something similar, with 2.3.8?
Another option could be to have a script call cyradm with a list of
cyradm localhost < file_containing_cyradm_commands
However, this is interactive & requires a password; is there a way to
get around this so I can pass the cyradm commands directly from a script?
Thank you,
Jessi B.
Downtown Emergency Service Center
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
--------------------------------------------------------------------------------
M.Menge Tel.: (49) 7071/29-70316
Universitaet Tuebingen Fax.: (49) 7071/29-5912
Zentrum fuer Datenverarbeitung mail:
***@zdv.uni-tuebingen.de
Waechterstrasse 76
72074 Tuebingen
Jessi Berkelhammer
2007-10-15 18:08:50 UTC
Permalink
Hi,

I'm still unclear about this. According to the perldocs, it is
recommended *not* to:
use Cyrus::IMAP::Admin::Shell;

Does anybody know why is this not recommended?

Ideally, I could use shell scripts to create a file with the cyradm
commands, and run those. Is there a way to do this so it doesn't require
the password to be entered interactively?

Thanks again,
Jessi
Message: 4
Date: Sat, 13 Oct 2007 20:48:45 +0200
Subject: Re: running cyradm commands from a script
Content-Type: text/plain; charset="iso-8859-1"
Hi,
with Cyradm is writen in perl and cyrus comes a perl packet you can use
to do all things you do with cyradm with perl.
Have a lock at cyrus-imapd-2.3.8/perl/imap
perldoc Cyrus::IMAP # imclient library
perldoc Cyrus::IMAP::Admin # administrative library
perldoc Cyrus::IMAP::Shell # cyradm shell
Post by Jessi Berkelhammer
Hello.
In order to automate some processes, I was hoping to run cyradm from a
script. The O'Reilly "Managing IMAP" book specifies how cyradm can
evaluate Tcl commands, by passing the 'file' option to cyradm. Old man
pages for cyradm online also show the option to pass a file parameter.
However, that isn't an option for 2.3.8, which we are running. Is there
a way to do this, or something similar, with 2.3.8?
Another option could be to have a script call cyradm with a list of
cyradm localhost < file_containing_cyradm_commands
However, this is interactive & requires a password; is there a way to
get around this so I can pass the cyradm commands directly from a script?
Thank you,
Jessi B.
Downtown Emergency Service Center
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
Glennie Vignarajah
2007-10-16 07:18:09 UTC
Permalink
Le Monday 15 October 2007, Jessi Berkelhammer(Jessi Berkelhammer
<***@desc.org>) a écrit:


Hello,
Post by Jessi Berkelhammer
Ideally, I could use shell scripts to create a file with the
cyradm commands, and run those. Is there a way to do this so it
doesn't require the password to be entered interactively?
Try something like this
cyradm -u MY_LOGIN -w MY_PASSWORD MY_HOST << CYRADMSCRIPT
lm
lam user.*
CYRADMSCRIPT
Hope this helps!
--
http://www.glennie.fr
Tout est drôle, dès l'instant que ça arrive aux autres.
Marcelo Maraboli
2007-10-18 11:25:25 UTC
Permalink
Post by Glennie Vignarajah
Le Monday 15 October 2007, Jessi Berkelhammer(Jessi Berkelhammer
Hello,
Post by Jessi Berkelhammer
Ideally, I could use shell scripts to create a file with the
cyradm commands, and run those. Is there a way to do this so it
doesn't require the password to be entered interactively?
Try something like this
cyradm -u MY_LOGIN -w MY_PASSWORD MY_HOST << CYRADMSCRIPT
lm
lam user.*
CYRADMSCRIPT
Hope this helps!
the easiest way to do this is to use the EXPECT language...

script for adding users from command-line:

---
#!/usr/local/bin/expect -f
#
# usage: cyrus-adduser.exp john.doe
#
set user [lindex $argv 0]
#
#
spawn /usr/local/bin/cyradm -u cyrus localhost
expect "assword:"
send "your_password\r"
expect "host>"
#
send "cm user/$user \r"
expect "host>"
#
send "sq user/$user 153600\r"
expect "host>"
#
send "exit\r"
expect eof
#
------------


regards,
--
MSc. Marcelo Maraboli Rosselott
Jefe Area de Redes y Comunicaciones (Network & UNIX Systems Engineer)
Ingeniero Civil Electronico, CISSP (MSc., Electronic Engineer, CISSP)

Direccion Central de Servicios Computacionales (DCSC)
Universidad Tecnica Federico Santa Maria phone: +56 32 2654071
Chile. http://www.usm.cl http://elqui.dcsc.utfsm.cl
Loading...