Operating System - OpenVMS
1753775 Members
7457 Online
108799 Solutions
New Discussion юеВ

Converting VMS Internal Date Fmt to Date Strings in DCL

 
SOLVED
Go to solution
Jack Trachtman
Super Advisor

Converting VMS Internal Date Fmt to Date Strings in DCL

I'm writing a DCL script to access Authorize records from SYSUAF.DAT. (Note: this will be read-only.) I can easily access a record via READ/KEY=username. There are a number of fields in the file that are formated as VMS 8-byte date format (either as absolute dates or as delta dates).

Is there any way within DCL to convert these to their sring equivalents (either "dd-mmm-yyyy hh:mm:ss" or "d hh:mm:ss" as appropriate)?
4 REPLIES 4
Jon Pinkley
Honored Contributor

Re: Converting VMS Internal Date Fmt to Date Strings in DCL

See Hein's response dated Aug 22, 2007 21:46:05 GMT in the following thread for an example of getting last login date from UAF.

The same technique works for any other binary date.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1155146

Jon
it depends
John Gillings
Honored Contributor
Solution

Re: Converting VMS Internal Date Fmt to Date Strings in DCL

Jack,

It's buried in amongst Hein's code. The magic incantation is

$ time_string=F$FAO("!%D",F$CVUI(32,32,F$FAO("!AD",8,binary_time)))

where binary_time is a symbol containing a string with the 8 byte binary time value.

Strictly speaking the sequence is undocumented and unsupported. It depends on an interaction between the implementation of strings in DCL and the "blindness" of F$FAO passing arguments to SYS$FAO.

On the other hand, someone would have to try pretty hard to break it, without breaking a whole bunch of supported stuff...
A crucible of informative mistakes
Robert Atkinson
Respected Contributor

Re: Converting VMS Internal Date Fmt to Date Strings in DCL

Jack, I'd recommend GETUAI (http://vms.process.com/scripts/fileserv/fileserv.com?GETUAI) which is a command line tool to retreive UAF information into symbols.

You can still read down SYSUAF.DAT to get the username, but it's much easier to return information using the utility.

Example:

$START:
$ DEFINE SYS$OUTPUT SYS$TEMP:UAFMAN_CPL_'PRCPID'.TMP
$ UAF SHOW */BRIEF
$ DEASS SYS$OUTPUT
$ !
$ OPEN /WRITE OUTFILE UAFMAN$TEMP:UAFMAN_CPL_REPORT.TMP
$ OPEN /READ INFILE SYS$TEMP:UAFMAN_CPL_'PRCPID'.TMP
$ READ /END=ERROR INFILE DUMMY ! Dump headers
$ READ /END=ERROR INFILE DUMMY ! Dump headers
$ !
$LOOP:
$ READ /END=END_LOOP INFILE INDATA
$ !
$ USER = F$EDIT(F$EXT(21,15,INDATA),"TRIM")
$ !
$ GETUAI 'USER' /UIC=UIC
$ !
$ IF F$EXT(0,4,UIC) .EQS. "[250" .OR. F$EXT(0,4,UIC) .EQS. "[310"
$ THEN
$ ELSE
$ GOTO LOOP
$ ENDIF
$ !
$ GETUAI 'USER' /PWLIFE=PWDLIFE /OWNER=OWNER /ACCOUNT=ACCOUNT
$ !
$ IF PWDLIFE .NES. " 60 00:00:00.00"
$ THEN
$ WS "%UCPL-I-PWLIFE, User ''USER' has a password life of ''PWDLIFE', owner ''OWNER', group ''ACCOUNT'"
$ WRITE OUTFILE "%UCPL-I-PWLIFE, User ''USER' has a password life of ''PWDLIFE', owner ''OWNER', group ''ACCOUNT'"
$ ENDIF
$ !
$ GOTO LOOP
$ !
Jack Trachtman
Super Advisor

Re: Converting VMS Internal Date Fmt to Date Strings in DCL

Thanks - this gives me what I need.

I read about the $FAO system service & read the threads pointed to in the answer. Makes sense.