use Expect; $Expect::Debug = 1; my $string= '/usr/bin/ssh x.x.x.x' my $exp=Expect->spawn($string) || die "error $!\n"