Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No output after grep command #82

Open
spaniardmaximus opened this issue Mar 16, 2023 · 0 comments
Open

No output after grep command #82

spaniardmaximus opened this issue Mar 16, 2023 · 0 comments

Comments

@spaniardmaximus
Copy link

spaniardmaximus commented Mar 16, 2023

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);
            }
        });
    }
@spaniardmaximus spaniardmaximus changed the title No output No output after grep command Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant