What is a quick and easy way to validate if the pattern "301 domaname.com 200" is present within BASH when spread across multiple lines of output?
I was using something like the following:
awk '/301|domain.com|200/' pcregrep -M '301|domain\.com|200'
but the order doesn't matter. I'm not sure how to state it so it does. What I thought would work apparently isn't catching the line endings.
pcregrep -M '301.*domain\.com.*200'
I'm building a small mod_rewrite server and I need a way to monitor what domains are getting redirected to what destinations.
As a result I'm assembling a small Nagios check script that will handle this for me.
What I have so far is the following:
curl qa-mod-rewrite.domain.com -i -I -L HTTP/1.1 301 Moved Permanently Via: 1.1 GREGORY Connection: close Proxy-Connection: close Date: Thu, 14 Nov 2013 16:35:19 GMT Location: http://qa.domain.com/ Content-Type: text/html; charset=iso-8859-1 Server: Apache/2.2.3 (CentOS) HTTP/1.1 200 OK Via: 1.1 GREGORY Connection: Keep-Alive Proxy-Connection: Keep-Alive Content-Length: 56772 Expires: -1 Date: Thu, 14 Nov 2013 16:35:03 GMT Content-Type: text/html; charset=utf-8 Server: Microsoft-IIS/7.5 Cache-Control: no-cache, no-store Pragma: no-cache X-AspNet-Version: 2.0.50727 Set-Cookie: cfcausa.qa#sc_wede=1; path=/ Set-Cookie: ASP.NET_SessionId=i4z1c4ahqoiw13552z413hbs; path=/; HttpOnly X-Powered-By: ASP.NET