Wednesday, December 27, 2006

shell script using expect for cvs automation

Hello PPL,

I always have to check the cvs status using cvs status command, so I tried to automate these things using expect
Expect is a tool for automating interactive
applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really
makes this stuff trivial. Expect is also useful for testing these same
applications. And by adding Tk, you can also wrap interactive applications in
X11 GUIs.
Home page http://expect.nist.gov/

#!/bin/bash

status=$(expect -c "spawn cvs -z9 -d :ext:blog@cvshostname:/path/cvsroot status
expect {password: { send \"password\r\"; exp_continue }
}
exit
")
echo ""
echo "$cvsstatus" > cvsstatus.txt

###continue your shell script after here####

####exit from script#######

Same you can use with ssh, telnet or ftp.
Let me know if some one have better thing with expect package because I am also new with scripting and expect :(

Thanks