Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-8817

mongoimport process sends everything to stderr

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • drivers

    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

      Attachments

        Activity

          People

            steve.renaker@mongodb.com Steve Renaker (Inactive)
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 21 weeks, 5 days ago