Karthikeyan Dhanapal
Posted on July 31, 2018
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)
)
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.
Posted on July 31, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.