Once again I am vexed by 'parse' and wondering if anyone can point me in the right direction.
I am trying to parse a log file. Naturally the company that produces the log file does not make it easy. I have lines that can look like these two examples:
Configured from console by jsmith on vty0 (10.1.250.78)
Configured from memory by console
The two items I want to pull out are the user ID ('jsmith' on the first line and 'console' on the second), and the IP address between the parentheses (present on the first line only).
I have been using the following code, which works on the first line because there is something following the user ID:
parse/case WS-MSG [
thru ' by ' copy WS-USERID TO ' '
thru '(' copy WS-FROM TO ')'
]
It works on the first line because I can parse to the space following the user ID. On the second line, it doesn't work, probably because there is no space after the word 'console' because the line ends there.
So what I want to do is parse through the string ' by ' and then pick up whatever follows that up to EITHER the next space OR the end of the line. That's the part I don't know how to code: Up to EITHER the next space OR the end of the line.
With all that 'parse' can do I can't believe it can't do that, so I wonder if someone could explain.
Thank you. (Yes, I am reading manual but it is a bit confusing for me.)