title: ECHO not working correctly when executing via Windows batch file
body: <p>I am attempting to write a simple batch script that our users can use to redeploy a bit of code to an environment if that environment has been recently refreshed and wiped of our changes.</p>
  
  <p>The script works great, but it is not quite logging the way I want it to. Do to restrictions with our deployment process (I am not the DBA, just a developer), we cannot include ECHO commands in the files.</p>
  
  <p>To get around this, as part of my batch script, I create a <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch2.htm#sthref414" rel="nofollow">login.sql</a> file in the working directory that contains "SET ECHO ON" and "SPOOL file.log APPEND" commands. The goal was that this would be executed before the scripts and spool my output. However, while the SPOOL command seems to be working, the scripts' contents are not being ECHOed.</p>
  
  <p>Here is the relevant code from the batch script:</p>
  
  <pre><code>:: Identify all files that begin with a number and end with .sql and write to a file.
  dir /b *.sql | findstr /b "[0-9]" &gt; ScriptsToImplement.txt
  
  :: Show the user the files to be executed and confirm whether to proceed
  echo The following scripts will be executed in %DB%:
  for /f "delims=" %%i in (ScriptsToImplement.txt) do echo %%i
  echo:
  set /p PROCEED=Proceed with implementation? [y/n] ^&gt;
  if /i "%PROCEED%" NEQ "y" (goto :opt_to_terminate)
  
  :: Build the user profile SQL file that will be executed after logging into SQLPlus
  :: This allows for the spooling of the output without having the SPOOL command declared in the file.
  echo SET ECHO ON &gt;&gt; login.sql
  echo SPOOL %DB%~%FOLDER%~%DATESTAMP%.log APPEND &gt;&gt; login.sql
  
  :: Go through the SQL files in the text file and execute them in the specified database.
  for /f "delims=" %%i in (ScriptsToImplement.txt) do (
  echo exit | sqlplus -L -S %DB_USER%/%DB_PASS%@%DB% @%%i
  if %errorlevel% NEQ 0 (@echo an error occurred with applying %%i; stopping further script execution... &amp; pause &amp; goto :terminate) else (@echo %%i was applied successfully) &gt;&gt; %DATESTAMP%_run_all.log
  )
  </code></pre>
  
  <p>My understanding is since this is launching a separate SQL*Plus session with every separate script, it is calling the login.sql file every time and so should be using the SET ECHO ON command every time.</p>