redis shell交互

#!/bin/bash

password="AizhanWordNode"

/usr/bin/expect <<EOF
#    set time -1
    spawn redis-cli -h 61.146.178.31 -p 6372
    expect {
        "61.146.178.31:6372" { send "auth $password\r" }
       exp_continue
    }
    expect "OK" { send "ping 1\r" }

#    expect "OK" { send "keys IcpPq*\r" }
#    expect {
#        "integer*" { send "keys IcpPq*\r" exp_continue }
#        "empty array" { send "keys IcpPq*\r" }
#    }

#    expect {
#        "integer*" { send "llen IcpSiteCustom\r" exp_continue }
#        "empty array" { send "llen IcpSiteCustom\r" }
#    }
    #exp_sleep 5
    #expect "integer*" { send "llen IcpSiteCustom\r" }

    expect "\"1\"" { send "llen IcpSiteCustom\r" }
    expect "integer*" { send "lrange IcpSiteCustom 0 1\r" }
    exp_sleep 1

    expect "*1)*" { send "llen IcpSiteCustom\r" }
    expect "integer*" { send "lrange IcpSiteCustom 0 20\r" }

    expect "*1)*" { send "exit\r" }
    expect eof
EOF

echo -e "OVER\n"
#!/bin/bash

password="AizhanWordNode"

/usr/bin/expect <<EOF
    set time 60
    spawn redis-cli -h 61.146.178.31 -p 6372
    expect {
        "61.146.178.31:6372" { send "auth $password\r" }
       exp_continue
    }
    expect "OK" { send "keys IcpPq*\r" }

    expect {
        "integer*" { send "keys IcpPq*\r" }
        "empty array" { send "keys IcpPq*\r" }
    }
    expect "empty array" { send "llen IcpSiteCustom\r" }
    expect "integer*" { send "llen IcpSiteCustom\r" }

    expect eof
EOF