- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Diplaying TOP 10 messages of a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО11-27-2005 11:01 PM
тАО11-27-2005 11:01 PM
I need to display first 10 messages from a file that contains more than 150 messages which is created by running an executable in VMS. I want to write a dcl script for the user, who on click will get only first 10 messages on his screen.
Pls suggest.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 11:20 PM
тАО11-27-2005 11:20 PM
Re: Diplaying TOP 10 messages of a file
HELP OPEN
HELP IF
HELP READ
HELP WRITE
HELP GOTO
HELP CLOSE
A UNIX "head" program might also be useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 11:49 PM
тАО11-27-2005 11:49 PM
Re: Diplaying TOP 10 messages of a file
$ ON CONTROL_Y THEN GOTO clean_up
$ max_lines = 10
$ IF P1 .EQS. "" THEN INQUIRE P1 "Enter File Name "
$ IF F$SEARCH(P1) .EQS. ""
$ THEN
$ WRITE SYS$OUTPUT "File ''P1' not found "
$ GOTO clean_up
$ ENDIF
$ OPEN/READ in 'P1'
$r_loop:
$ READ/END_OF_FILE=end_file in record
$ WRITE SYS$OUTPUT record
$ max_lines = max_lines -1
$ IF max_lines .GT. 0 THEN GOTO r_loop
$!
$end_file:
$ CLOSE in
$clean_up:
$ IF F$TRNLNM("in") .NES. "" THEN CLOSE IN
$ EXIT
Hope that helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-27-2005 11:50 PM
тАО11-27-2005 11:50 PM
Re: Diplaying TOP 10 messages of a file
What VMS version?
Beginning in V7.3-2 SEARCH has some real nice new features.
$ SEARCH
will do what you are asking.
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2005 01:12 AM
тАО11-28-2005 01:12 AM
Re: Diplaying TOP 10 messages of a file
Do you mean the first lines in the file, like the Unix 'head' command?
If you have perl installed, that solves as:
perl -pe "last if $. > 10" x.c
explanation:
-p = loop through input reading into variable $_ printing $_ at block end.
-e = program text coming up
last = exit loop
$. = current line in input
> 10 = your top choice
Using a standard VMS tool like edt, you could (pre-)create a command sequence:
$ create top_ten.edt
set nonumbers
type 1:10
quit
$
$edit/edit/command=top_ten.edt your-data
Or do you mean a sort of statistics function, finding the messages which occur most often? Then the solution in perl gets trickier
perl -ne "$x{$_}++; END {foreach (sort {$x{$b}<=>$x{$a}} keys %x) {last if ++$i > 10; print ""$x{$_} $_"" }}" your-data
-n = loop through input, but do not print
-e = program
$x{$_}++ = (create and) increment element with key $_ in array %x
END = do this when input exhausted
keys %x = all keys from array, in a list
sort = sort, normally by key value, but here we provide a sort routine comparing not the key values, but the pointed to array values.
foreach = loop through list setting $_ each time
last if ++$i > 10 = your output cut-off choice
print = finally... what we came to do.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2005 02:22 AM
тАО11-28-2005 02:22 AM
Re: Diplaying TOP 10 messages of a file
>> perl -pe "last if $. > 10" x.c
The x.c was the text I tested with.
To be replaced by 'your_data'.
>> $edit/edit/command=top_ten.edt your-data
That was of course supposed to be: EDIT/EDT
Some folks will need EDITXX/EDT, or just EDT to deal with local defintions for EDIT or EDT.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2005 04:10 AM
тАО11-28-2005 04:10 AM
Re: Diplaying TOP 10 messages of a file
There is one more good VMS freeware (Hunter Goatley's) 'extract' utlity.
You can download and install it within a minute from http://vms.process.com/scripts/fileserv/fileserv.com?EXTRACT
It has so many facilities such as selecting any number of records from the biginning, middle, or end of one file or more files and optionally performs various modifications before displaying on the screen.
Syntax and example
$ extract /record=([START=m,END=n,COUNT=k]) file1, file2...
$ extract /record=(start=5, count=15) file1
---> displays 10 lines starting from 5th line.
$ extract /head=k file1
$ extract /head=10 file1
--->displays top 10 lines
$ extract /tail=k file1
$ extract /tail=10 files
---> displays bottom 10 lines
We are using this for long time. And there few more freeware utilities avalible for VMS, but I feel this is very easy.
Archunan
Archie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2005 08:36 AM
тАО11-28-2005 08:36 AM
Re: Diplaying TOP 10 messages of a file
As others have said, it depends on what you mean by "message". If you mean "line" the most obvious is the V7.3-2 and higher SEARCH command. You don't need to use /NOR as suggested by Jan, just search for a null string:
$ SEARCH file ""/LIMIT=10
You can combine this with /SKIP to select any range of the file you like. For example, suppose you wanted 10 lines starting at line 25:
$ SEARCH file ""/SKIP=25/LIMIT=10
If your messages contain a specific string, search for that, again with /LIMIT
Another option is TYPE/PAGE combined with SET TERM/PAGE:
$ SET TERMINAL/PAGE=10
$ TYPE/PAGE file
Of course, this leaves your terminal at 10 pages, which probably isn't a good idea! Save and restore like this:
$ p=F$GETDVI("SYS$COMMAND","TT_PAGE")
$ SET TERMINAL/PAGE=10
$ TYPE/PAGE file
$ SET TERMINAL/PAGE='p'
Your users will need to hit ^Z to exit from the display, or can hit RETURN or any other commands for TYPE/PAGE.
Less likely to be useful, but worth knowing about is DUMP/RECORD=(START:s,COUNT:c)
This dumps "c" records starting at record "s" (0 based), however, the output probably isn't what you're looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2005 09:06 PM
тАО12-05-2005 09:06 PM
Re: Diplaying TOP 10 messages of a file
Thanks a lot I could complete the job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-05-2005 09:29 PM
тАО12-05-2005 09:29 PM
Re: Diplaying TOP 10 messages of a file
MY VMS version is 7.1, so search command as suggested by john is not working. It is also not possible to load any additional freeware as suggested.
I have completed the job now,
Heinz,
Is it possible to take the final 10 messages to a file instead of displaying it on screen, so that I cam mail that file to end user. Pls if u can write few lines as before it will help me.