use Net::SSH::Expect; use strict; use warnings; #login to a remote host my $ssh = Net::SSH::Expect->new (host => "ipaddr", password=> 'pwd', user => 'username', raw_pty => 1); my $login_output = $ssh->login(); #### my $cpscp = $ssh->exec("copy scp install ip addr filename"); my $usr = $ssh->waitfor ("Enter usename for remote scp server:\s*\z ", 5); if ($usr) { print("string found \n"); my $pwd =$ssh->send("root"); } else { print("No string found\n"); } #### $ssh->waitfor('Enter username for remote scp server:\s*\z ', 5) or die "not found"; $ssh->send("root");