Thursday, October 1, 2009

ssh grep string using spaces causing problems

while running the following command using automated ssh i faced the following issue

ssh pmg-message1 grep -C50 "Oct 1 00:00:00 127.0.0.1 \(--- \) time taken=3ms, 20013, TEXT, MT" /app/pmg/archived_logs/pmg.log.2.gz


grep: 1: No such file or directory
grep: 00:00:00: No such file or directory
grep: 127.0.0.1: No such file or directory
grep: (---: No such file or directory
grep: ): No such file or directory

This string which i am trying to search is special for two reasons
1) the search string contains special characters ( and ), therefore i used escape sequence.
2) if this query was being run without ssh it is fine but for ss we need to add extra enclosing symbols ' '.as below


ssh pmg-message1 'grep -C50 "Oct 1 00:00:00 127.0.0.1 \(--- \) time taken=3ms, 20013, TEXT, MT" /app/pmg/archived_logs/pmg.log.2.gz'

No comments:

Setting the limits in Linux permanently

https://singztechmusings.wordpress.com/2011/07/11/ulimit-how-to-permanently-set-kernel-limits-in-linux/ app soft nofile   16384 * hard...