I have a LDAP query that I'm inputting to a script via stdin. I want to search for specific values, and possibly more than one, and then send the found value via stdout.
My LDAP query looks as such:
discover-repository-location=null, File Name=null, date-detected=Tue Jun11 12:44:14 UTC 2013, endpoint-machine-name=null, incident-id=545527, sender-ip=12.1.141.87, sender-email=WinNT://tmpdm/tmpcmp, Assigned To=null, sender-port=-null, endpoint-domain-name=null, Business Unit=null, endpoint-dos-volume-name=null, file-access-date=null, date-sent=Tue Jun 11 12:44:14 UTC 2013, endpoint-file-name=null, file-modified-by=null, Country=null, Manager Email=null, plugin-chain-id=1, discover-server=null, data-owner-name=null, Dismissal Reason=null, Last Name=null, First Name=null, Phone=null, subject=HTTP incident, Sender Email=null, UserID=null, endpoint-user-name=null, endpoint-volume-name=null, discover-name=null, discover-content-root-path=null, data-owner-email=null, file-create-date=null, endpoint-application-name=null, Employee Code=null, Region=null, Manager First Name=null, path=null, endpoint-application-path=null, Manager Last Name=null, Department=null, discover-location=null, protocol=HTTP, Resolution=null, file-owner=null, Postal Code=null, endpoint-file-path=null, Title=null, discover-extraction-date=null, Script-attribute=null, Manager Phone=null, file-created-by=null, file-owner-domain=nul
And say I want to pull out the protocol or the sender-email attributes from this query, which reads in as a single line. I can simply read it in by:
while read stdin line; do
echo $line
done
Now I can check that these attributes exist, however I am having trouble grabbing the value that is in the key-value pair. I am trying to do so with regular expressions in bash. I'd like to grab the full value using '=' and ',' as the delimiters, and then possibly use regular expression to validate that I've grabbed a correct value from my attribute (as a safety check, and for logging purposes).
Any input would be useful and greatly appreciated.