例 expect&ssh † sshで接続して、lsを実行。 #!/usr/bin/expect set timeout 5 spawn ssh somehost.example.com expect "password:" send "YOUR PASSWD\r" expect "Last login" send "ls\r" interact ↑ 例. expect&sendmail † sendmailをexpectで叩いてメール送信。テスト送信を何回もやるとき便利。 #!/usr/bin/expect set timeout 5 spawn telnet somehost.example.com 25 expect "somehost.example.com" send "helo somehost.example.com\n" expect "pleased to meet yo