running cyradm commands from a script

Marcelo Maraboli marcelo.maraboli at usm.cl
Thu Oct 18 07:25:25 EDT 2007


Glennie Vignarajah wrote:
> Le Monday 15 October 2007, Jessi Berkelhammer(Jessi Berkelhammer 
> <jberkelhammer at desc.org>) a écrit:
> 
> 
> Hello,
> 
>> 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


More information about the Info-cyrus mailing list