title: Redirecting stdin/stdout to/from a remote host via ssh
body: <p>I'm trying to write a perl script that redirects its stdin to a remote machine and at the same time redirects the stdout of the remote machine to its stdout:</p>
  
  <pre><code>callingProgram &lt;--&gt; myScript &lt;--&gt; sshTunnelToRemote
  </code></pre>
  
  <p>See <a href="https://stackoverflow.com/questions/4769986/git-clone-from-remote-ssh-repository-change-the-machine-on-the-remote-network-b">this question</a> and bdonlan's answer for the purpose of the script.</p>
  
  <p>First I tried to use the <code>open2()</code> function from the IPC library but for reasons described <a href="http://perldoc.perl.org/perlipc.html#Bidirectional-Communication-with-Another-Process" rel="nofollow noreferrer">here</a> it doesn't seem to be a good approach, I didn't even get a simple <code>grep</code> command working.</p>
  
  <p>My second idea was to use the <code>Net::SSH::Perl</code> or the <code>Expect</code> libraries but they're not available on the machine where the script is supposed to be executed and I can't install libraries there.</p>
  
  <p>So my question is what could be a simple way to achieve what I want? Solutions using [ba]sh or even C++ are also possible. The targeted platform is Solaris 10.</p>