title: Cygrunsrv & autossh : A way to embedd remote commands in the command line?
body: <p>I'm using cygrunsrv and autossh on windows XP to create a service building a tunnel to a remote server but i also want to create another tunnel from the remote server to another server.</p>
  
  <p>I can achieve it with this command line :</p>
  
  <pre><code>autossh -M 5432 serverA -t 'autossh -M 4321 serverB -N'
  </code></pre>
  
  <p>but when I want to set it up in cygwin through cygrunsrv to make it works as a service :</p>
  
  <pre><code>cygrunsrv -I TUNNEL -p /usr/bin/autossh -a "-M 5432 serverA -t 'autossh -M 4321 serverB -N'" -e AUTOSSH_NTSERVICE=yes -e AUTOSSH_POLL=20 -e AUTOSSH_GATETIME=30
  </code></pre>
  
  <p>It's not fully working. The service is creating the tunnel correctly to ServerA but it's not sending the autossh command "autossh -M 4321 serverB -N" to ServerA.
  I tried to escape the quote but all my efforts didn't make any difference and I'm not seeing any command sent in the autossh logs.</p>
  
  <p>I think the problem is related to pseudo terminal that is not created through the cygrunsrv.</p>
  
  <p>I'd like to know if there's a way to fix my cygrunsrv command line to make it work or should I consider a different approach ?</p>