Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js hubot execute commands on the server

I am trying to execute a command on the server using hubot. This example works for me:

  robot.respond /(cmd)/i, (msg) ->
    doing = spawn 'ls', ['-la']
    doing.stdout.on 'data', (data) ->
      msg.send data.toString()

However, I need to change the folder before I execute the command I want to execute. What I want hubot to run is:

cd /var/folder && some-command

but changing the folder from the hubot script doesn't work.

The executed command has a lot of files loaded based on the folder it resides in so it seems I have to go to this folder.

How can I make hubot execute a command from a specific path?

like image 429
Alex Avatar asked Mar 04 '26 10:03

Alex


1 Answers

process.chdir('/var/folder')

is what I was looking for.

like image 139
Alex Avatar answered Mar 06 '26 22:03

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!