open RSH, "| ssh foo\@bar /bin/sh >out.log 2>err.log" or die "ssh command failed"; select RSH; $|=1; print RSH "ls\n";