Query on awk

Hi All,

Through awk am trying to get the exact match from the application log in remote server. The application log in the remote server have parenthesis. The log file is as below.

ERROR Car is not available due to error while checking car price. Error detail: (CarService.checkAvailabilityAndUpdateItinerary)
However am getting the below error. Could you please help.

awk: cmd. line:1: /ERROR
awk: cmd. line:1: ^ unterminated regexp

ssh user@hostip awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"

Passing ssh arguments has the principle problem that they are interpreted (and expanded) twice, once on the calling site and once on the called site.
In this simple case you can nest two types of quotes

ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"'

More robust is a here document, and passing the script through stdin

ssh user@hostip /bin/sh << "EOT"
awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/"
EOT

The quotes around the terminating EOT do minimal expansion on the calling site.

The highest robustness requires two scripts

ssh user@hostip /bin/sh < remotescript. sh

Thanks for the reply.
I followed the first approach the result is getting as Zero. We do have the said pattern in the remote server.

ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/" ' /home/folder1/file.log | wc -l
##########################################################



###########################################################

0



The outer 'string' must contain the entire remote command(s)

ssh user@hostip 'awk "/ERROR Car is not available due to error while checking car price/&&/Error detail/&&/CarService.checkAvailabilityAndUpdateItinerary/" /home/folder1/file.log | wc -l'

Thanks a lot. The issue is resolved.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.