Receiving Timed out errors when executing piped commands (output redirection) using Custom:execute methods (execute, executeForString, executeForNumber).

Receiving Timed out errors when executing piped commands (output redirection) using Custom:execute methods (execute, executeForString, executeForNumber).

book

Article ID: KB0092376

calendar_today

Updated On:

Products Versions
TIBCO Hawk -
Not Applicable -

Description

Resolution:
When you call an executable using one of the execute methods of the Custom microagent, you cannot use redirection (|), multiple command (;) or append characters (> and >>). You can create a separate script that includes a command with these characters, then call that script from the microagent method.

This is mentioned in the Hawk document -> Administrator's Guide -> Chapter 9    Performing Common Monitoring Tasks : Monitoring with Custom Scripts -> Tips on Monitoring Custom Scripts.

For example, if you execute the command: "ls -l | wc -l" from the Custom:executeForNumber directly. You will receive an error message:

MicroAgent returned error.


Java.IO.Exception: Timed out waiting for output from process ls -l | wc -l

Instead, you should create a script to include this command and echo the result to stdout. The script could resemble the following:

#!/usr/bin/sh
RESULT=`ls -l | wc -l`
echo $RESULT

Issue/Introduction

Receiving Timed out errors when executing piped commands (output redirection) using Custom:execute methods (execute, executeForString, executeForNumber).