botpress / v12

Botpress OSS – v12
https://v12.botpress.com
GNU Affero General Public License v3.0
81 stars 90 forks source link

Can BOTPRESS Javascript we execute batch files? #564

Closed SUPRIYO05 closed 5 years ago

SUPRIYO05 commented 5 years ago

Make sure these checkboxes are checked before raising an issue, thank you!

Please also fill in these fields:


Botpress version: <<VERSION HERE>>

Channels: <>

EFF commented 5 years ago

@SUPRIYO05 can you provide a little more detail & context. The issue title is not clear.

SUPRIYO05 commented 5 years ago

We do have a number of selenium java bots residing on machine. They need to be submitted based on intent occurence. Looking for options to execute them. Know that exposing as rest api can be an option but presently its not viable.

epaminond commented 5 years ago

@SUPRIYO05 , for sure you can execute bash-commands in node-apps. E.g. check https://stackoverflow.com/questions/37732331/execute-bash-command-in-node-js-and-get-exit-code

SUPRIYO05 commented 5 years ago

I tried to use the following code in botpress( code kept in path '..\Botpress\data\global\actions'.

  var sys = require('sys')
    var exec = require('child_process').exec;
    function puts(error, stdout, stderr) { sys.puts(stdout) }
    exec("ls -la", function(err, stdout, stderr) {
      console.log(stdout);

Error: err:Module "sys" not found. Tried these locations: "..\Botpress\data\global\actions"

epaminond commented 5 years ago

@SUPRIYO05 , you aren't using neither puts function nor sys module. Did you try to remove them from code-snippet? I don't think this is botpress-related issue.

SUPRIYO05 commented 5 years ago

Thanks All for your suggestions. Still I get some issues

Code: var bat_exec = require('child_process').exec; exec("ls -la", function(err, stdout, stderr) { console.log(stdout); });

I am getting error in first line:

err:Module "child_process" not found. Tried these locations: "...Documents\Botpress\data\global\actions"

epaminond commented 5 years ago

@SUPRIYO05 , child_process is builtin node module. So this could be an issue with node set up on your side.

SUPRIYO05 commented 5 years ago

Thanks! any help please?

SUPRIYO05 commented 5 years ago

I have opened one more issue in node Js forum, but if any one has experienced this earlier. My version of node JS is 10.15.0

SUPRIYO05 commented 5 years ago

Just now I built a code as below in NODE.JS

/ Hello, World! program in node.js / console.log("Hello, World!") var bat_exec = require('child_process').exec; bat_spawn("dir", function(err, stdout, stderr) { console.log(stdout); });

It worked perfectly fine and displayed output.

Path from where executed: "...Documents\train_nodJS"

My point is why when executed from BOT press its only checking in ""...Documents\Botpress\data\global\actions" path. Why its not looking for system default? Bot the above paths are under same hiererchy?

Also these scripts called for actions, are they node.JS or Javascript? Sorry I am a core ERP guy and now trying to get into these domains.

Regards

Supriyo

SUPRIYO05 commented 5 years ago

Anyone any thoughts please?