I am trying to run command with ssh and I am getting value not sure how to use await and async here so that I can close thread once it saves data into DB
require('dotenv').config()
const db = require('../lib/db');
const exec = require('ssh-exec')
var getModems = new Promise(function(resolve, reject) {
var v_host = '122.12.19.160'
exec('proxysmart-remote.sh list_online_modems', {
user: 'root',
host: v_host
}).pipe(process.stdout , function (err, data) {
resolve(data);
})
});
const saveModems = function () {
getModems.then(function(value) {
// save into db
console.log(value);
});
}
saveModems()
process.exit();