#!/usr/bin/expect -f set timeout -1 set host [lindex $argv 0] set password [lindex $argv 1] set cmd [lindex $argv 2] spawn ssh -o StrictHostKeyChecking=no root@$host $cmd expect { "password:" { send "$password\r" exp_continue } eof }