title: how to capture error conditions in windows ftp scripts?
body: <p>I am using windows batch scripts to run ftp scripts automatically. Where the set of ftp commands I want run is saved in a file.</p>
  
  <p>example:</p>
  
  <pre><code>@echo off 
  ftp -n -i -s:c:\temp\myftpscriptfile.ftp
  </code></pre>
  
  <p>I have used the %ERRORLEVEL% syntax to successfully capture error conditions in the batch commands.  My challenge is the ftp script command is always returning an ERRORLEVEL of 0 even when the commands inside the script fail.</p>
  
  <p>I am having difficulty figuring out how to have the ftp script actually return or trap when errors occur inside it. It will simply run through the commands blindly and even though i can see the errors echoed on screen I can't capture them as an ERRORLEVEL..</p>
  
  <p>Sample screen shot of trying script which fails to login and then echoing the ERRORLEVEL which shows a zero..</p>
  
  <pre><code>ftp&gt; open fubar.test.com
  Unknown host fubar.test.com
  ftp&gt; user test test
  Not connected.
  ftp&gt; ascii
  Not connected.
  ftp&gt; cd /home/test/dirname
  Not connected.
  ftp&gt; mput C:\Test\test*.txt
  Not connected.
  ftp&gt; close
  Not connected.
  ftp&gt; quit
  .0
  </code></pre>