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