Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
error when converting file in json with cs-import-document command in my nodejs code

In my nodejs code, I am using a module called node-cmd to use the command cs-import-documents from the package of amazon cloudsearch tools.

On my local computer, it is working, I am able to convert my files and then upload the json files on cloudsearch. I am working with webstrom on windows 10. But I want it to work in my ec2 instance, so I creat an nodejs instance ec2 with elastic beanstalk on aws and I access it in ssh to try to execute my code.

So is it the module that is not working on the ec2 or the command? Maybe there is an other better way to do this? The cs-import-command is working when I use it in command line.

Here is my code:

function commandToJson(dest, fileName){
var res = fileName.replace("&", "^&");
var resJsonName = utils.basename(res);
var commande = 'cs-import-documents --source "' + dest + '\\' + res + '" --output "' + dest + '\\' + resJsonName + '"';
console.log(commande);
cmd.get(
    commande,
    function(data, err, stderr){
        if (!err) {
            console.log('\n --------------retour console---------------- : \n\n',data);
            var jsonName = utils.basename(fileName);
            uploadToCloudsearch(relTempPath + jsonName + '1.json');
        } else {
            console.log('error', err)
        }
    }
);

}

Here is the error I get:

error { Error: Command failed: /./cloudsearch/cloud-search-tools-v2-2.0.1.0-2014.10.27/bin/cs-import-documents --source "TEMP/Questions and Answers on CSDR" --output "TEMP/Questions and Answers on CSDR"

at ChildProcess.exithandler (child_process.js:206:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

killed: false, code: 1, signal: null, cmd: '/./cloudsearch/cloud-search-tools-v2-2.0.1.0-2014.10.27/bin/cs-import-documents --source "TEMP/Questions and Answers on CSDR" --output "TEMP/Questions and Answers on CSDR"' }

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I manage to resolve it. I needed to set the variables for the root profil and then run my code in root.

To hardcode it so you don't need to type export each time I would recommend putting it in your .bashrc or .bash_profile for each corresponding user(Root,ec2-user,etc). These files will be in /home/ec2-user/ or /root/ for example. You can see what you currently have setup and active by simply typing "env" Depending on your setup you can put it in either one of these. like:

export CS_HOME=/usr/local/aws/bin/cloud-search-tools-v2-2.0.1.0-2014.10.27
export PATH=$PATH:$CS_HOME/bin
export AWS_CREDENTIAL_FILE=/home/ec2-user/.aws/creds
export CS_ENDPOINT=cloudsearch.us-east-1.amazonaws.com

What's the difference between .bashrc, .bash_profile, and .environment?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!