Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
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
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
- here i'm hoping to have a message w/ either stdout or stderr depending on if it succeeded/failed
end