Wednesday, May 16, 2007

Expect - Automation era


In this section I will be showing how to automate interactive sessions with "expect"

Beginning with a very simple example. Suppose you have a very simple script like this.

$ cat test.sh
#!/bin/sh
echo "Whats your name"
read name
echo "Hello $name"

Here is expect script "test.exp" to automate the above script

#!/usr/bin/expect -f

spawn ./test.sh

expect "Whats your name"
send "RAJA\r"
interact

$ expect test.exp
spawn ./test.sh
Whats your name
RAJA
Hello RAJA

Note:: I will be adding a detailed page for expect very soon here.

No comments:

© Jadu Saikia www.UNIXCL.com