[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

437.0. "USER has xx new messages." by MOSAIC::WATERS (Lester Waters) Tue Mar 31 1987 15:42

    Does anyone out there have or know of a tool that would allow
    a query of the number of mail messages that a particular user
    has pending?  For those of you familiar with the TOPS-20 command
    
    			INFORMATION MAIL <username>
        
    This command would respond:
    
    			Mail from SENDER at 11:53
    
    Of course, the recipient could modify his/her mail file protection
    so that this command couldn't be done by the average user.
    
    I would settle for something that would just tell me how many pending
    mail messages a user has (e.g., "USER has 10 new messages").
    Where is this mailcount information kept?  I would be interested
    in both a version that did not require privileges (if possible),
    and a version which did.
    
T.RTitleUserPersonal
Name
DateLines
437.1Who has the record format?FROST::HARRIMANDebates...DiscussionsTue Mar 31 1987 15:5521
    
    Still hacking TOPS-20, Lester?
    
      The New Mail Count as well as other personal information about
    a user (personal name, purge-on-exit, etc.) is kept in VMSMAIL.DAT
    which lives in SYS$SYSTEM:... This is usually not world readable,
    but I don't see why you couldn't write a higher-level (i.e.
    installable) utility to look up a username (isn't the key to that
    file the vms username?) and blurt out the new mail count. 
    
      I remember someone (Callas I think) mentioning that VMSMAIL.DAT
    is changing big-time come V5 VMS. Also I don't remember the format
    of VMSMAIL.DAT or whatever it's going to be called being published
    anywhere. I do remember a previous topic about this with some of
    the format. Didn't someone write a "mail$ssn.mai" cleanup program
    and post it here?
    
    Sounds pretty simple though. If I had the record format it could
    be knocked off in an afternoon :-)
    
    /pjh
437.3Already in the ToolShedSWAMI::LAMIACheap, fast, good -- pick twoTue Mar 31 1987 16:163
    See tool CHECKMAIL in the ToolShed.  The catalog conference is on
    METOO::TOOLS$LIBRARY:SW_TOOLS_CATALOG.  Do a SHOW/KEY/FUL CHECKMAIL
    to find the its entry.
437.4Here's a dcl version.SKIVT::JARVISGarth JarvisTue Mar 31 1987 16:27344
This is a modification of sys$examples:mailuaf.com that I use.  I think it
has all the items you're looking for.

-g


$!             <<< CSC32::SYS$COMMON:[NOTES$LIBRARY]MAILUAF.NOTE;1 >>>
$!                          -< VMSMAIL Data maintainer >-
$!================================================================================
$!Note 5.0                        Some enhancements                     No replies
$!DELNI::CANTOR "Dave Cantor"                         332 lines  29-SEP-1986 09:26
$!--------------------------------------------------------------------------------
$!
$!      Here is a copy of my enhancements to MAILUAF.COM.
$!
$!      Some of the features I've added:
$!
$!      1.  Single line execution; _e.g._, $ @MAILUAF SHO FOOBAR
$!
$!      2.  Adjust the new mail count
$!
$!      3.  Rename a user record, by copying the record (thus transferring
$!      the new mail count, forwarding, etc.) and zeroing the new mail 
$!      count in the old record.
$!
$!      (I've already sent this by private mail to the moderator.)
$!      
$!      Dave C.
$!
$ !++
$ !
$ !  MAILUAF.COM - Modify SYS$SYSTEM:VMSMAIL.DAT
$ !
$ !
$ !  ABSTRACT:	Sample command procedure to modify
$ !		SYS$SYSTEM:VMSMAIL.DAT
$ !
$ !		This command procedure will prompt
$ !		the user for a command.  The valid
$ !		commands are:
$ !
$ !		ADD username	- Add a new user to SYS$SYSTEM:VMSMAIL.DAT
$ !		CANCEL username - Cancel mail forwarding for username
$ !		EXIT		- Exit from this procedure
$ !		HELP		- Type help message
$ !		MODIFY username - Modify mail forwarding address for username
$ !		REMOVE username - Remove username from SYS$SYSTEM:VMSMAIL.DAT
$ !		SHOW username 	- Display mail information about username
$ !		LIST		- List forwarding addresses for all users 
$ !             RENAME username newusername - Rename a username
$ !
$ !
$ !  REQUIRED PRIVILEGES:
$ !		BYPASS
$ !
$ !		
$ !  IMPLICIT OUTPUT:
$ !		SYS$SYSTEM:VMSMAIL.DAT will be created if it does
$ !		not exsist.
$ !
$ !
$ !--
$ if = "IF"
$ inquire = "INQUIRE"
$ open = "OPEN"
$ goto = "GOTO"
$ write = "WRITE"
$ create = "CREATE"
$ type = "TYPE"
$ read = "READ"
$ close = "CLOSE"
$ exit = "EXIT"
$ ask = "inquire/nopunctuation"
$ prev_priv = f$setprv("SYSPRV")
$ sysmai = "SYS$SYSTEM:VMSMAIL.DAT"
$ open /share=write /read /write /error=no_file f1 'sysmai'
$ goto file_open
$no_file:
$ write sys$output sysmai," not found...creating new file"
$ create /fdl=sys$input 'sysmai'	!Create new VMSMAIL.DAT
IDENT	VMS MAIL Information data file

FILE
	ALLOCATION              10
	BEST_TRY_CONTIGUOUS     yes
	BUCKET_SIZE             2
	CONTIGUOUS              no
	EXTENSION               10
	GLOBAL_BUFFER_COUNT     0
	ORGANIZATION            indexed
	OWNER                   [001,004]
	PROTECTION              (system:RWE, owner:RWE, group:, world:)

RECORD
	BLOCK_SPAN              yes
	CARRIAGE_CONTROL        none
	FORMAT                  variable
	SIZE                    0

AREA 0
	ALLOCATION              10
	BEST_TRY_CONTIGUOUS     yes
	BUCKET_SIZE             2
	CONTIGUOUS              no
	EXTENSION               10

KEY 0
	CHANGES                 no
	DATA_KEY_COMPRESSION    yes
	DATA_RECORD_COMPRESSION yes
	DATA_AREA               0
	DATA_FILL               100
	DUPLICATES              no
	INDEX_AREA              0
	INDEX_COMPRESSION       yes
	INDEX_FILL              100
	LEVEL1_INDEX_AREA       0
	NULL_KEY                no
	PROLOGUE                3
	SEG0_LENGTH             31
	SEG0_POSITION           0
	TYPE                    string
$ open /share=read /read /write f1 'sysmai'
$file_open:
$ on control_y then goto done
$ immediate_command = f$edit(p1+p2+p3+p4+p5+p6+p7+p8,"trim") .nes. "" 
$ if .not. immediate_command then goto do_command
$! We have an "immediate command"
$ line = p1 + " " + p2 + " " + p3 + " " + p4 + " " + p5 + " " + p6 -
            + " " + p7 + " " + p8
$ goto first_command
$ !
$ ! Main loop.  Get command and username then dispatch
$ !
$do_command:
$ if immediate_command then goto done
$ ask line "MAILUAF> "
$first_command:
$ line = f$edit(line,"trim,compress,upcase,uncomment")
$ if line .eqs. "" then goto done
$ command = f$edit(f$element(0," ",line),"trim")
$ user = f$edit(f$element(1," ",line),"trim")
$ seconduser = f$edit(f$element(2," ",line),"trim")
$ if f$locate(command,"HELP") .eq. 0 then goto help_user
$ if f$locate(command,"EXIT") .eq. 0 then goto done
$ if f$locate(command,"LIST") .eq. 0 then goto list_users
$ if user .eqs. "" then goto syntaxerr
$ fulluser = f$fao("!31AS",user)
$ if f$locate(command,"ADD") .eq. 0 then goto add_user
$ if f$locate(command,"CANCEL") .eq. 0 then goto cancel_user
$ if f$locate(command,"MODIFY") .eq. 0 then goto modify_user
$ if f$locate(command,"REMOVE") .eq. 0 then goto remove_user
$ if f$locate(command,"SHOW") .eq. 0 then goto show_user
$ if f$locate(command,"ADJUST") .eq. 0 then goto adjust_user
$ if seconduser .eqs. "" then goto syntaxerr
$ fullseconduser = f$fao("!31AS",seconduser)
$ if f$locate(command,"RENAME") .eq. 0 then goto rename_user
$rename_user:
$ read /index=0 /err=nosuchuser /key="''fulluser'" f1 record
$ record1 = record
$ record1[0,31] := "''seconduser'"
$ write /err=no_rename f1 record1
$ read /index=0 /err=nosuchuser /key="''fulluser'" f1 record
$ record[%x21*8,16] = 0
$ write /update f1 record
$ write sys$output "User ",user," zeroed"
$ goto do_command
$no_rename:
$ write sys$error "Could not rename ''user' as ''seconduser'."
$ goto do_command
$help_user:
$ type sys$input:

 ADD username		Add a new user
 CANCEL username	Cancel forwarding for a user
 EXIT			Exit from MAIUAF
 HELP			Type this
 MODIFY username	Modify forwarding address for a user
 REMOVE username	Remove a user completely
 SHOW username		Show MAIL information about user
 LIST			List forwarding addresses for all users in VMSMAIL.DAT
 ADJUST username	Adjust new mail count for a user
 RENAME username newusername      Rename a user record

$ goto do_command
$add_user:
$ read /index=0 /err=add_10 /key="''fulluser'" f1 record
$ write sys$output "User ",user," record already exists"
$ goto do_command
$add_10:
$ s1 = "''record'"
$ if f$length(s1) .ne. 0 then $ delete/symbol record
$ record[0,31]:='user'
$ record[248,288]=0
$ ask address "Forwarding address? "
$ t1 = f$length(address)
$ record[536,8]='t1'
$ record[68,'t1']:='address'
$ write f1 record
$ write sys$output "User ",user," added"
$ goto do_command
$cancel_user:
$ read /index=0 /err=nosuchuser/key="''fulluser'" f1 record
$ address = f$extract(68,255,record)
$ addr_length = f$cvui(67*8,8,record)
$ address := 'address'
$ naddress = f$extract(0,addr_length,address)
$ t2 = f$length(address)
$ t2 = 't2' - 'addr_length'
$ if addr_length .eq. 0 then goto show_10
$ write sys$output "User ",user,", forwarding address is ",naddress
$ ask yn "Cancel mail forwarding? "
$ if .not. yn then goto do_command
$ record[536,8]=0
$ record[68,255] := "''f$extract(68+addr_length,255-addr_length,record)'"
$ record = f$extract(0,68+'t2',record)
$ write /update f1 record
$ goto do_command
$list_users:
$ close f1
$ open /share=write /read /write f1 'sysmai'
$ write sys$output ""
$ write sys$output "Username                        Forwarding address"
$ write sys$output "--------                        ------------------"
$list_10:
$ read /end=do_command f1 record
$ user = f$extract(0,31,record)
$ addr_length = f$cvui(67*8,8,record)
$ address = f$extract(68,255,record)
$ address := 'address'
$ address = f$extract(0,addr_length,address)
$ write sys$output user,"	",address
$ goto list_10
$ goto do_command
$adjust_user:
$ read /index=0 /err=nosuchuser /key="''fulluser'" f1 record
$ new_mail_count = f$cvui(%x21*8,16,record)
$ write sys$output "New message count is ",new_mail_count
$ ask adj_mail_count "Enter new mail count:  "
$ if adj_mail_count .eqs. "" then goto do_command
$ if f$type(adj_mail_count) .nes. "INTEGER" then goto do_command
$ delta = adj_mail_count .lt. 0 .or. f$extract(0,1,adj_mail_count) .eqs. "+" 
$ if .not. delta then record[%x21*8,16] = f$integer(adj_mail_count)
$ if delta then record[%x21*8,16] = new_mail_count + f$integer(adj_mail_count)
$ write /update f1 record
$ write sys$output "User ",user," modified"
$ goto do_command
$modify_user:
$ read /index=0 /err=nosuchuser /key="''fulluser'" f1 record
$ address = f$extract(68,255,record)
$ addr_length = f$cvui(67*8,8,record)
$ naddress = f$extract(0,addr_length,address)
$ t2 = f$length(address)
$ if addr_length .ne. 0 then goto xx1
$ write sys$output "User ",user," does not have forwarding enabled"
$ goto xx2
$xx1:
$ write sys$output "Current forwarding address is ",naddress
$xx2:
$ ask naddress "New forwarding address? "
$ if naddress .eqs. "" then goto do_command
$ address = f$extract(addr_length,t2-addr_length,address)
$ t1 = f$length(naddress)
$ record[536,8]='t1'
$ record[68,255]:="''naddress'''address'"
$ record = f$extract(0,68+t1+t2,record)
$ write /update f1 record
$ write sys$output "User ",user," modified"
$ goto do_command
$nosuchuser:
$ write sys$output "User ",user," record does not exist"
$ goto do_command
$remove_user:
$ read /index=0 /err=nosuchuser/key="''fulluser'" f1 record
$ address = f$extract(68,255,record)
$ addr_length = f$cvui(67*8,8,record)
$ address := 'address'
$ if addr_length .eq. 0 then goto xx0
$ address = f$extract(0,addr_length,address)
$ write sys$output "User ",user,", forwarding address is ",address
$ goto xx9
$xx0:
$ write sys$output "User ",user," does not have forwarding enabled"
$xx9:
$ ask yn "Remove? "
$ if .not. yn then goto do_command
$ read /index=0/key="''fulluser'" /delete f1 record
$ goto do_command
$show_user:
$ read /index=0 /err=nosuchuser /key="''fulluser'" f1 record
$ copy_self_send = f$cvui(31*8+0,1,record)
$ copy_self_reply = f$cvui(31*8+1,1,record)
$ auto_purge = f$cvui(31*8+2,1,record)
$ other_flags = f$cvui(31*8,8,record) .and. .not. %x7
$ new_mail_count = f$cvui(%x21*8,16,record)
$ address = f$extract(68,255,record)
$ addr_length = f$cvui(67*8,8,record)
$ fnmlng=f$cvui(66*8,8,record)
$ dirlng=f$cvui(65*8,8,record)
$ address := 'address'
$ full_name := "''f$extract(68+addr_length,fnmlng,record)'"
$ dir_spec  =  f$extract(addr_length+fnmlng,dirlng,address)
$ blankno = "NO|"
$ onoff = "enabled|disabled"
$ write sys$output "User ",user," has AUTO_PURGE ",-
     f$element(auto_purge,"|",onoff)
$ write sys$output "User ",user,"'s COPY_SELF flags are ",-
     f$fao("!ASSEND,!ASREPLY.",f$element(copy_self_send,"|",blankno),-
           f$element(copy_self_reply,"|",blankno))
$ if other_flags .eq. 0 then -
     write sys$output "User ",user," has no other flags."
$ if other_flags .ne. 0 then -
     write sys$output "User ",user," flags:  ",f$fao("!2XL",other_flags)
$ if new_mail_count .eq. 0 then -
     write sys$output "User ",user," has no new mail."
$ if new_mail_count .ne. 0 then -
     write sys$output "User ",user," has ",-
     f$fao("!ZL new message!%S.",new_mail_count)
$ if dirlng .eq. 0 then goto no_dir
$ write sys$output "User ",user,", MAIL subdirectory is ",dir_spec
$ goto test_full_name
$no_dir:
$ write sys$output "User ",user," did not specify a MAIL subdirectory"
$test_full_name:
$ if fnmlng .eq. 0 then goto no_pers_name
$ write sys$output "User ",user,", MAIL personal name is ",full_name
$ goto check_forward
$no_pers_name:
$ write sys$output "User ",user," does not have a MAIL personal name."
$check_forward:
$ if addr_length .eq. 0 then goto show_10
$ address = f$extract(0,addr_length,address)
$ write sys$output "User ",user,", forwarding address is ",address
$ goto do_command
$show_10:
$ write sys$output "User ",user," does not have forwarding enabled"
$ goto do_command
$syntaxerr:
$ write sys$output "Command syntax error"
$ goto do_command
$done:
$ close f1
$ prev_priv = f$setprv(prev_priv)
$ exit
437.5BISTRO::HEINIf We don&#039;t Have it,You don&#039;t Need it!Wed Apr 01 1987 03:4317
    Here is a shortish example I once made. Ofcourse it is heavily
    dependent on the VMSMAIL.DAT format and as such bound to 
    break come V5.0. Note that SYSPRV is required unless you happen
    to hold an identifier that allows you to access VMSMAIL.DAT.
    
$if p1.eqs."" then $p1=f$getjpi("","username")  !Default to own user name
$oldpriv=f$setprv("sysprv")			!Get SYSPRV and save old.
$open/read/share vmsmail sys$system:vmsmail.dat
$read/key="''p1'" vmsmail user_mail_record
$close vmsmail                                 	!Got all we want. CLose.
$newmail_count=f$cvsi(0,16,f$extract(33,2,user_mail_record))
$if newmail_count.eq.0 then $write sys$output "No new mail"
$if newmail_count.eq.1 then $write sys$output newmail_count, " New Mail message."
$if newmail_count.gt.1 then $write sys$output newmail_count, " New mail messages."
$oldpriv=f$setprv(oldpriv)                	!Restore initial privileges.
    
    Hope this helps, Hein van den Heuvel, Valbonne
437.6Don't assume SYS$System:TALLIS::FISHERKay R. FisherFri Apr 10 1987 08:4315
VMSMail.dat does not have to live in SYS$SYSTEM:.
Check the logical "VMSMAIL" before you use SYS$SYSTEM:vmsmail.dat.

For clusters that don't want all the I/O going to their system disk
vmsmail.dat, jbcsysque.dat, sysuaf.dat, netuaf.dat have been copied to
quiet disks.  Usually the old file is left behind (to help survive VMS
upgrades) so if you read or modify the SYS$SYSTEM: version of the file
you are either using or creating stale data.

              _!_
Bye        ----O----
Kay R. Fisher / \
 
==============================================================

437.7just "VMSMAIL", eh?KALLON::EIRIKUREir�kur Hallgr�mssonTue Apr 14 1987 17:197
    re .6: Kay, is the logical simple "VMSMAIL"?   This would be real
    handy to get my LAVC workstation mail count back in synch, but it
    doesn't work for me.  Are there any other things that you have to
    do besides create this logical?
    
    	Eirikur
    
437.8ERIS::CALLASSo many ratholes, so little timeWed Apr 15 1987 10:483
    Did you define the logical in exec mode? It should work that way.
    
    	Jon
437.9MONSTR::DUTKONestor Dutko, VMS/VAXclusters CSSEWed Apr 15 1987 18:5219
    The definition of the logical as a system and executive mode is only 
    relevent if it is NOT in the SYS$SYSTEM directory.
    
    I believe that Kay's reference was to Hein's command procedure.
    It assumes the file is in SYS$SYSTEM.  This is an incorrect assumption.
    Somthing of the following should be performed:
    
$ VMSMAIL_FILE := SYS$SYSTEM:VMSMAIL.DAT
$ IF F$TRNLNM("VMSMAIL","LNM$SYSTEM_TABLE",,"EXECUTIVE",,"VALUE") .NES. "" -
     THEN VMSMAIL_FILE := 'F$TRNLNM("VMSMAIL","LNM$SYSTEM_TABLE",,"EXECUTIVE",,"VALUE") '
    
    and use the VMSMAIL_FILE symbol as the filename.
    
    The command procedure indicated does not decrement the counts as
    well.  The currently "support" method of doing this is to read all
    your mail messages and then issue the READ /NEW command "x" times,
    where "x" is the amount of mail messages your count is off by.
    
    -- nestor
437.10READ/NEW is only required onceLA780::LONGOBob LongoThu Apr 16 1987 17:557
    RE: .9
    
    Actually, the READ/NEW is only required once no matter how many
    new messages VMSMAIL.DAT thinks you have.  You don't have to READ/NEW
    once for each new message you supposedly have.
    
    -Bob
437.11Pointer to MAILUAF conferenceDELNI::CANTORDave C.Sun Apr 19 1987 19:148
      There is a whole conference on this topic at 
      
                   CSC32::MAILUAF    (Hit KP7 blah blah)
      
      from which my command procedure modifications were quoted in
      .4 of this note. 
      
      Dave C.