I need help with my regex to grab my host information from this logfile:
Tue Aug 24 10:22:14 2010: test1.colo_lvm:check:INFO: host=test1.dom.colo.name.com
Tue Aug 24 10:22:14 2010: test1.colo_lvm:check:INFO: "/home/bin64"/admin --user="foo-bar" --password="*****" --host="test1.dom.colo.name.com" --port="9999" --socket="/tmp" variables
My regex is also grabbing the 2nd line to include the hostname in double quotes and other pieces of data on that line, which I am not interested in. The first line is fine only. So, I’m just interested in
test1.dom.colo.name.com and nothing else.
My regex so far is this:
if ($line =~ m/(host=)(.+)/){
Thanks!
It’ll work better if you exclude spaces and quotes from the match:
By excluding quotes this will match the
host=...in the first line while ignoring the--host="..."in the second line.Edit: This simple test script works for me on your sample input. What happens if you run this?