#!/usr/bin/expect -f set password [lindex $argv 0] set command [lrange $argv 1 end] eval spawn $command expect "asswor" { send -- "$password\r" } set timeout 3600 expect eof