DEV Community

Karthikeyan Dhanapal
Karthikeyan Dhanapal

Posted on

Hubot - SSH Server Status

Hi. I am writing a coffee script to check the server status. It was written in coffee script for hubot. I am getting some error while getting the arguments from the child_process function. I am pasting the code below for the understanding.

Code:

child_process = require 'child_process'
module.exports = (robot) ->
robot.respond /check status/i, (res) ->

child_process.exec("sshpass -p 'password' ssh username@hostname 'sudo service httpd status'", (err, stdout, stderr) ->
  if err
    console.log(err)
  else
    console.log(stdout)
)
Enter fullscreen mode Exit fullscreen mode

Code explanation:

This(child_process) is a nodejs module and i am trying to perform the following task:

using ssh shell command i am logging into the server (ssh username@hostname) and then writing the shell command for checking the status of the server (sudo service httpd status).

Error: Response not ok: no_text

I think there is some problem with the child_process.exec() syntax.

I am using centos in virtual machine. I have saved the ssh public key in the .ssh/authorize_keys

Thanks.

Top comments (0)