[comp.os.vms] Program to get VMSMAIL.DAT information

bruceb@telesoft.UUCP (Bruce Bergman @spot) (09/23/87)

A short while ago I noticed a Pascal program float across this newsgroup
which would display some information from the VMSMAIL.DAT file.

Realizing that not everyone has Pascal (or would want it...  :^), I wrote
the following .COM file to do the same thing.  This also displays another
piece of information the original program didn't; the number of new messages
waiting to be read by that user.  Sorry it didn't get out sooner -- I've
only had some spare time just recently.

It does not assume you have privilege to read the data file, however it
will quit gracefully if you don't have the required privilege or haven't
made the data file world readable.  

To use it, simply cut between the lines (it's too short to shar) and save
it in the file VMSMI.COM.  Create a symbol which executes this file and
everything will be all set.  It is very simple to use and will prompt you
for the required information.  Example:

    $ VMSMI :== @<some-path>VMSMI.COM
    $ VMSMI
        :
        : (program executes...)
        :
    $

Have fun!

bruce bergman

----- cut here ----- cut here ----- cut here ----- cut here ----- cut here -----
$ !    VMS Mail information
$ !    By Bruce A. Bergman
$ !    Last modified: 22-Sep-87
$ !
$ !    Set up for errors
$ !
$ set noon
$ on control then goto QUIT
$ on error then goto QUIT
$ !
$ !    Open the mail information file
$ !
$ write sys$output "VMS Mail Information.  Press <CTRL/Z> to quit."
$ write sys$output ""
$ datafile = "SYS$SYSTEM:VMSMAIL.DAT"
$ open/share/read/error=FAIL mailfile 'datafile'
$ !
$ !    Determine whom we are checking for and where
$ !
$AGAIN:
$ read/prompt="Enter username: "/end_of_file=QUIT/error=QUIT sys$command user
$ user = f$edit("''user'", "UPCASE,COLLAPSE")
$ !
$ !    Get the mail info record
$ !
$ read/index=0/nolock/error=NOT_FOUND/key="''user'" mailfile record
$ !
$ !    Parse out information
$ !
$ newmsgs      = f$cvui(33*8, 8, record)
$ mail_len     = f$cvui(65*8, 8, record)
$ personal_len = f$cvui(66*8, 8, record)
$ forward_len  = f$cvui(67*8, 8, record)
$ !
$ !    Display number of new mail messages
$ !
$ write sys$output "Number of new messages: ''newmsgs'"
$ !
$ !    Starting position of variable length info
$ !
$ last_position = 68
$ !
$ !    Display forwarding address (if set)
$ !
$ if 'forward_len' .le. 0 then goto NO_FORWARD
$ forward = f$extract('last_position', 'forward_len', record)
$ write sys$output "Forwarding to: ''forward'"
$ last_position = 'last_position' + 'forward_len'
$ goto CHECK_PERSONAL
$NO_FORWARD:
$ write sys$output "No forwarding address set."
$ !
$ !    Display personal name (if set)
$ !
$CHECK_PERSONAL:
$ if 'personal_len' .le. 0 then goto NO_PERSONAL
$ personal = f$extract('last_position', 'personal_len', record)
$ last_position = 'last_position' + 'personal_len'
$ write sys$output "Personal name: ""''personal'"""
$ goto CHECK_MAIL
$NO_PERSONAL:
$ write sys$output "No personal name set."
$ !
$ !    Display mail directory (if set)
$ !
$CHECK_MAIL:
$ if 'mail_len' .le. 0 then goto NO_MAIL
$ mail = f$extract('last_position'+1, 'mail_len', record)
$ write sys$output "Mail directory: SYS$DISK:[''user'''mail'"
$ write sys$output ""
$ goto AGAIN
$NO_MAIL:
$ write sys$output "Mail directory: SYS$DISK:[''user'] (default)"
$ write sys$output ""
$ goto AGAIN
$ !
$ !    Outta here
$ !
$QUIT:
$ close mailfile
$ exit
$ !
$ !    Error handlers
$ !
$NOT_FOUND:
$ write sys$output "No entry for ''user' in ''datafile'."
$ write sys$output ""
$ goto AGAIN
$FAIL:
$ write sys$output "Unable to open ''datafile' for input."
$ exit
----- cut here ----- cut here ----- cut here ----- cut here ----- cut here -----
-- 
allegra!\                         TeleSoft, Inc.
gould9!  \      crash!--\         (619) 457-2700 x123
ihnp4!    \              \
           >--sdcsvax!---->--telesoft!bruceb (Bruce Bergman N7HAW)
nosc!     /              /
scgvaxd! /     log-hb!--/         5959 Cornerstone Court West
ucbvax! /                         San Diego, CA.  92121-9891

All expressed opinions belong to "Bill the Cat" or me.  :^)