title: Escape characters in batch scripts
body: <p>I have the following script to automate uploading a file to a remote server. The problem is that the password I have been given is full of special characters which are killing the login process.</p>
  
  <p>Here is a changed version of the characters:</p>
  
  <blockquote>
    <p>j7~]%&amp;X</p>
  </blockquote>
  
  <p>When using a normal FTP application there isn't a problem. I have wrapped the password in quotes and have also tried using a <code>^</code> to escape the percentage and ampersand. However, it doesn't work. Also, I can't tell what the actual password is that is being sent.</p>
  
  <p>What could be going wrong or how do I reveal the password before it is sent? </p>
  
  <pre><code>:Source = http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/
  
  @echo off
  echo user myloginname&gt; ftpcmd.dat
  echo mypassword&gt;&gt; ftpcmd.dat
  echo bin&gt;&gt; ftpcmd.dat
  echo put %1&gt;&gt; ftpcmd.dat
  echo quit&gt;&gt; ftpcmd.dat
  ftp -n -s:ftpcmd.dat myserver
  del ftpcmd.dat
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>As mentioned below, I used the "type" command to see what was actually in the <code>ftpcmd.dat</code>. It turns out that, through a lot of trial an error and reading up on escape characters that you use different escape characters for different special characters!!!</p>
  
  <p>For an ampersand use a caret, and for the percentage use a percentage. So, given my password:</p>
  
  <p>j7~]%&amp;X</p>
  
  <p>the resulting password would be:</p>
  
  <p>j7~]%%^&amp;X</p>