[DOCS-8817] mongoimport process sends everything to stderr Created: 14/Sep/16  Updated: 03/Nov/17  Resolved: 29/Sep/16

Status: Closed
Project: Documentation
Component/s: drivers
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Steve Renaker (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

osx yosemite 10.10.5

Location: https://docs.mongodb.com/manual/reference/program/mongoimport/
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Referrer: https://www.google.com/
Screen Resolution: 1440 x 900


Participants:
Days since reply: 7 years, 21 weeks, 5 days ago

 Description   

Hello - I am trying to run mongoimport inside some ruby code, and determine if the import succeeded or failed. Unfortunately, it seems that mongoimport always sends to stderr, instead of stdout for success and stderr for failures.

This is my code - let me know if I'm mis-using, or if this is a bug!

Thanks,
Jacinda

def import_csv
Database.mongo_mapper_db # create a connection to the db

command = "mongoimport --db learnup --collection #

{@file_name}

--type csv --headerline --file #

{@file_path}

"

Open3.popen3(command) do |stdin, stdout, stderr, wait_thr|
standard_out = stdout.read
standard_err = stderr.read

puts "stdout is: " + standard_out
puts "stderr is: " + standard_err

  1. here i'm hoping to have a message w/ either stdout or stderr depending on if it succeeded/failed
    end


 Comments   
Comment by Steve Renaker (Inactive) [ 16/Sep/16 ]

jacindaz@gmail.com Hi Jacinda,

This forum is generally only for requests related to the documentation project. I would suggest you look for help at the MongoDB Google Group (https://groups.google.com/forum/#!forum/mongodb-user) and cite this ticket for further clarification or support.

Best regards,

  • Steve
Comment by Jacinda Zhong [ 16/Sep/16 ]

Thanks Steve - can you explain exactly which messages go to STDOUT, from which other tools, and why this decision was made?

Comment by Steve Renaker (Inactive) [ 16/Sep/16 ]

jacindaz@gmail.com Hi Jacinda,

All the MongoDB command line tools send status messages to STDERR, and use STDOUT for other kinds of output. If you'd like to check the success or failure of a shell command, you can check the exit code ($? in Ruby – there's a good description here: https://gist.github.com/defunkt/326968).

Thanks and best regards,

  • Steve
Comment by Steve Renaker (Inactive) [ 15/Sep/16 ]

jacindaz@gmail.com Hi Jacinda, thanks for filing this ticket. We're looking into the issue, and I'll let you know as soon as there's something to report. Best regards,

  • Steve
Comment by Jacinda Zhong [ 15/Sep/16 ]

Hello - I just created a jira account for mongo, I'm the original reporter. Let me know if you have other questions/thoughts about this ticket!

Generated at Thu Feb 08 07:57:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.