$Expect::Exp_Internal = 1; my $exp = Expect->new(); #$exp->log_stdout(1); $exp->spawn("scp test\.txt foo\@bar:/tmp/test\.txt ") or warn("Unable to spwan : $!"); $exp->expect(9, [ qr/Are you sure you want to continue connecting \(yes\/no\)\?/i, sub { my $self = shift; $self->send("yes\n"); exp_continue; }], [ qr/password:/i, sub { my $self = shift; $self->send("$passwd\n"); exp_continue; }]) or warn("error : " .$exp->exp_error());