title: mongo shell script won't let me include "use <database>"
body: <p>32-bit mongo 2.0.1 on a windows XP machine</p>
  
  <pre><code>//script filename: test.js  (one line shell script file to store a person)
  db.cTest.save({Name: "Fred", Age:21});
  </code></pre>
  
  <p>run against database dbTest by entering the following 2 shell commands:</p>
  
  <pre><code>    &gt; use dbTest
      switched to dbTest
      &gt; load("test.js")
  </code></pre>
  
  <p>So far, so good.</p>
  
  <p>But if I try and include the "use" statement in the script it fails:</p>
  
  <pre><code>//script filename: test.js  (including "use" statement)
  use dbTest;
  db.cTest.save({Name: "Fred", Age:21});
  </code></pre>
  
  <p>fails with error msg as follows:</p>
  
  <pre><code>    &gt; load("test.js")
      SyntaxError: missing ; before statement
      Mon Dec 19 11:56:31: Error: error loading js file temp.js (shell):1
  </code></pre>
  
  <p>Adding or removing semicolons to test.js doesn't seem to matter.</p>
  
  <p>So how do you put a "use" directive into a mongo shell script?</p>