Bash-check-redis-replication
Jump to navigation
Jump to search
Example of using expect within a bash script This will give you both the hosts as well as an exit code to check for failures.
SLAVED_HOSTS=`exec expect <<EOD set timeout 10 set send_slow {1 .3} spawn telnet localhost ${PORT} expect "Escape character is '^]'." send "auth ${USER}\r" expect "+OK" send "info replication\r" expect ">$" send "quit\r" EOD` RESULT=$?