HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: F$EXTRACT Help
Operating System - OpenVMS
1832182
Members
2862
Online
110038
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2007 01:39 AM
07-06-2007 01:39 AM
F$EXTRACT Help
I hope this is something pretty basic but I'm having problems with F$EXTRACT break strangely on white space.
Example of the log I am parsing:
Cache (HOST:20200444) Fri Jun 29 11:40:20 2007
Cache (HOST:20200444) Mon Jul 2 06:22:06 2007
The related code snipets:
$ EXACT_TIME = F$ELEMENT(6," ", LOG)
$ MESSAGE_HOUR = F$EXTRACT(0,4,EXACT_TIME)
$ WRITE SYS$OUTPUT MESSAGE_HOUR
The output:
2007
06:2
I wanted only the first two digits for the hour but to ensure that F$EXTRACT was getting confused with the year, I expanded it to four digits.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2007 02:20 AM
07-06-2007 02:20 AM
Re: F$EXTRACT Help
element 0 = Cache
element 1 = (HOST:20200444)
element 2 = Mon
element 3 = Jul
element 4 = 2
element 5 = 06:22:06
element 6 = 2007
Your three lines of DCL gives 2007 as the output. Element 5 is the time. Then you could use F$ELEMENT(0,":",EXACT_TIME)
to get the hour.
element 1 = (HOST:20200444)
element 2 = Mon
element 3 = Jul
element 4 = 2
element 5 = 06:22:06
element 6 = 2007
Your three lines of DCL gives 2007 as the output. Element 5 is the time. Then you could use F$ELEMENT(0,":",EXACT_TIME)
to get the hour.
____________________
Purely Personal Opinion
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2007 04:12 AM
07-06-2007 04:12 AM
Re: F$EXTRACT Help
It seems to me you fail to recognize that F$ELEMENT does not recognize natural words, but simply counts every single seperator.
I suspect that the line "jul 2" actually has an extra space, although that is not visible in this forum output.
If you want to pick up the 6'th word then you first have to compress mulltiple whitespace characters into 1.
Probably something like:
$ log_compressed = F$EDIT(LOG,"COMPRESS")
$ EXACT_TIME = F$ELEMENT(6," ", log_compressed)
Other example:
$ write sys$output f$ele(1," ","a b c")
b
$ write sys$output f$ele(1," ","a b c")
$ write sys$output f$ele(1," ",f$edit("a b c","compress"))
b
$
What problem are you really trying to solve?
I find that parsnig log file is MUCH easier in PERL or AWK once you get going a little bit with those tools.
In this case for example:
$ perl -lne "print $1 if /(\d+):\d\d:\d\d/" tmp.txt
11
06
The "REGULAR EXPRESSION" /(\d+):\d\d:\d\d/ give something to match on.
/ = start RE
( = start remembering in variable $1
\d+ = one or more of decimals (hours)
) = stop remembering
:\d\d = a piece of string starting with a colon and followed by two decimals (for the minutes)
:\d\d = a second piece of string starting with a colon and followed by two decimals (for the seconds)
/ = end RE
-l = print newline after each print
-n = loop through input file
-e = program text following.
Good luck!
Hein.
I suspect that the line "jul 2" actually has an extra space, although that is not visible in this forum output.
If you want to pick up the 6'th word then you first have to compress mulltiple whitespace characters into 1.
Probably something like:
$ log_compressed = F$EDIT(LOG,"COMPRESS")
$ EXACT_TIME = F$ELEMENT(6," ", log_compressed)
Other example:
$ write sys$output f$ele(1," ","a b c")
b
$ write sys$output f$ele(1," ","a b c")
$ write sys$output f$ele(1," ",f$edit("a b c","compress"))
b
$
What problem are you really trying to solve?
I find that parsnig log file is MUCH easier in PERL or AWK once you get going a little bit with those tools.
In this case for example:
$ perl -lne "print $1 if /(\d+):\d\d:\d\d/" tmp.txt
11
06
The "REGULAR EXPRESSION" /(\d+):\d\d:\d\d/ give something to match on.
/ = start RE
( = start remembering in variable $1
\d+ = one or more of decimals (hours)
) = stop remembering
:\d\d = a piece of string starting with a colon and followed by two decimals (for the minutes)
:\d\d = a second piece of string starting with a colon and followed by two decimals (for the seconds)
/ = end RE
-l = print newline after each print
-n = loop through input file
-e = program text following.
Good luck!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2007 04:18 AM
07-06-2007 04:18 AM
Re: F$EXTRACT Help
Yes. The second white space is what threw me off. I went ahead with a solution using F$EXTRACT.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP