-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Description
Hi, I'm trying to "grep" a log for an event and grab its timestamp. The code below only seems to work when a match its found, so I get Resolved ssh command execution, success, and the promise is resolved (timestamp) and returned back for further processing.
I'm stuck in that if there are no matches from the grep (because the event hasn't happened yet - I'm calling it periodically from a polling function), there is no "resolution". The only output that I see is success. How can I handle that lack of output?
So, technically, the command executed without errors but there is no stdout for it?
private async executeSSHCommand (command: string): Promise<string> {
return new Promise((resolve, reject) => {
try {
const client = new SSH(this.configOptions);
client.exec(command, {
out: eventOut => {
console.log(`Resolved ssh command execution ${ eventOut.toString() }`);
return resolve(eventOut.toString());
},
err: eventErr => {
console.log(`there is an error ${ eventErr.toString() }`);
return reject(eventErr);
}
}).start({
success () {
console.log('success');
},
fail () {
console.log('failed');
}
});
} catch (ex) {
console.log(`catch error: ${ ex.toString() }`);
return reject(ex);
}
});
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels