#!/usr/bin/expect set timeout -1 spawn sudo /tmp/debianzfs.sh /dev/vda expect "You selected to OVERWRITE '/dev/vda' as hostname 'debianzfs', are you sure? \\\[y/N] " send "y\r" expect "Enter passphrase:" send "password123\r" expect "Re-enter passphrase:" send "password123\r" expect "theunexpected"