title: using PLINK to Send a remote command with single and double quotes
body: <p>I'm trying to use plink on winXP to connect to a linux server and execute a command.  Here's the command line I'm running:</p>
  
  <p><code>plink some_profile cd "$(echo 'T:\somedir\somesubdir with space in it\' | sed 's_\\_/_g' | sed 's_T:_/media/drive1_g')";unrar x 'somefile.rar'</code></p>
  
  <p>If I execute the command portion of this (start with the cd) on the linux box directly it works perfectly.  But when I run it through plink, it fails with the following error:</p>
  
  <p><code>bash: line 0: cd: /media/drive1/somedir/somesubdir: No such file or directory</code></p>
  
  <p>I think I'm not quoting the command correctly when going through plink so it's not transferring the quotes needed to handle the spaces in the directories.  Any ideas on how this should be quoted so that it works?</p>
  
  <p>In case you're wondering why I'm even doing this, it's basically a script I'm running on Directory Opus where I can unrar the file I currently have highlighted (a samba mount).  The directory and filename are passed to the script which will the unrar that file on my remote box.</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT: Problem solved thanks to the response from Mikel.  Here is the line that works now in case anyone else comes across this later...</strong></p>
  
  <p><code>plink some_profile cd \"$(echo 'T:\somedir\somesubdir with space in it\' | sed 's_\\_/_g' | sed 's_T:_/media/drive1_g')\";unrar x 'somefile.rar'</code></p>