[SERVER-8211] Mongo Shell fails to capture stdout when it is redirected Created: 17/Jan/13  Updated: 11/Jul/16  Resolved: 17/Aug/13

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 2.3.2
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Thomas Boyd Assignee: Stennie Steneker (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Confirmed on OS X and Linux 64


Issue Links:
Related
is related to SERVER-8171 Logging to stdout can break in V8 Closed
Backwards Compatibility: Major Change
Participants:

 Description   

Cannot capture output from print() commands issued to mongo shell when running a script and redirecting stdout to a file. Shell behaves as expected in 2.2.2, but have confirmed the unexpected behavior in 2.3.2, and 2013-01-14 nightly.

$ rm it.log
$ cat it.js
print("Hello");
$ ./mongo --nodb ./it.js 1> it.log
$ cat it.log
MongoDB shell version: 2.3.3-pre-
$ ./mongo --nodb ./it.js
MongoDB shell version: 2.3.3-pre-
Hello
$



 Comments   
Comment by Stennie Steneker (Inactive) [ 17/Aug/13 ]

I retested in MongoDB 2.4.5 and the redirection works as expected.

Cheers,
Stephen

Comment by Tad Marshall [ 17/Jan/13 ]

Hi Thomas,

Thanks for the report. I think that this is SERVER-8171, fixed in commit https://github.com/mongodb/mongo/commit/ed4789001bc45371cd56d644baa54f0abaef0eb4 .

I was able to reproduce the problem following your steps in 2.3.2 on Mac OS/X downloaded from http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.3.2.tgz, but I do not see the problem in today's code.

This fix has not yet made it into a nightly build (due to test failures), but it will be in 2.4.0-rc0 which should be out within a few weeks. Can you try it again once 2.4.0-rc0 is out?

Thanks! Let me know how it works (or doesn't).

Tad

Generated at Thu Feb 08 03:16:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.