Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda