$ssh = Net::OpenSSH->new($hostname, user => $username, master_stderr_discard => 1} $command = "cd /usr/local/bin; interactive_program.pl"; @out = $ssh->capture({stdin_data => "input1\ninput2\ninput3\n"}, $command);