tpascale
tpascale

Reputation: 2576

mongo shell / simple example for windows XP

New to Mongo, just experimenting w the shell on a Windows XP machine running Mongo 2.0.1.

At the ">" mongo.exe cmd prompt, what do I enter in order to read cmds from another file called TEST.js ? I put a TEST.js file every place I could think of, and typed things like ">./mongo TEST.js", ">.mongo full-pathname.js", ">TEST.js", etc.

Is there a way to do this ?

(Why?: I loaded a bunch of data w mongoimport & thought I could try a quick-and-dirty mapreduce from the > shell prompt prior to setting up via a ruby or python driver & doing it the right way. The map,reduce & finalize funcs are sitting in a *.js file, and I need those function defs imported before I can run the mapreduce method on my data collection.)

Upvotes: 0

Views: 2274

Answers (1)

Tad Marshall
Tad Marshall

Reputation: 1363

From the Windows XP command prompt, you can run the mongo shell (mongo.exe in Windows) with the "--shell" option followed by your filespec to start the mongo shell, load your file and then remain in the mongo shell. If your file defines "map" and "reduce" functions, those will be available to you at the mongo shell's prompt.

For example, "mongo --shell TEST.js" .

Alternatively, you can start the mongo shell and then issue a "load" command to load your JavaScript file. The command 'load("TEST.js")' should do it for you.

If these are functions you will want every time you start the mongo shell, you can put the JavaScript into a file named ".mongorc.js" (note the initial period) in your "user" directory, for example "C:\Documents and Settings\YourName\.mongorc.js" on Windows XP when logged in as YourName. The .mongorc.js feature was introduced in version 1.9, so your version has it.

Upvotes: 5

Related Questions