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"' }