DEV Community

Karthikeyan Dhanapal
Karthikeyan Dhanapal

Posted on

2

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay