Wednesday, February 9, 2011

Using expect script inside shell script

Written small sample shell script which contains expect script, which connect to ftp server.

SCRIPT:-

#!/bin/sh
echo "shell script starting"
ls
sleep 2
pwd
sleep 2
clear
echo "expect is starting"
expect -c "
spawn ftp 192.168.0.250
expect ":"
send \"user_name\r\"
sleep 1
expect "Password:"
send \"user_passed\r\"
sleep 1
expect "ftp\*"
send \"bye\r\"
sleep 1
expect eof"
echo "expect ended bash script follows"
ls -l
sleep 1
pwd
sleep 2

No comments: