Ahhhhh...VMS and DCL. <warm fuzzy>
I couldn't find an easy way to do this without possibly screwing up other
things, so you'll need to do this from a DCL command procedure ("shell
script"), because the date format displayed in the DIRECTORY command depends
on where in the world you are (I think it's the LIB$DT_DATE_FORMAT logical,
but I forget). So, try this:
1) Copy the following into a file called "LSLRT.COM" on your VMS box.
$!--------------- START CUT HERE ------------------------
$ ON WARNING THEN GOTO end
$ ON CONTROL_Y THEN GOTO end
$!
$ in_dirspec = F$PARSE(p1,"*.*;*",,,"SYNTAX_ONLY")
$ IF F$EDIT(P1,"UPCASE,COLLAPSE").EQS."-D"
$ THEN
$ sortorder = ",DESC"
$ in_dirspec = F$PARSE("","*.*;*",,,"SYNTAX_ONLY")
$ ENDIF
$!
$ IF F$EDIT(P2,"UPCASE,COLLAPSE").EQS."-D"
$ THEN
$ sortorder = ",DESC"
$ ELSE
$ sortorder = ""
$ ENDIF
$!
$ wso := WRITE SYS$OUTPUT
$ wsf := WRITE schn
$ delete := delete
$ DateStamp = F$CVTIME("",,"YEAR")+F$CVTIME("",,"MONTH")+ -
F$CVTIME("",,"DAY")
$ TimeStamp = F$CVTIME("",,"HOUR")+F$CVTIME("",,"MINUTE")+ -
F$CVTIME("",,"SECOND")
$ sortspec = "SYS$SCRATCH:LSLRT_" + DateStamp + TimeStamp + -
F$GETJPI("","PID") + ".TMP"
$ CREATE 'sortspec'
$ OPEN/READ/WRITE schn 'sortspec'
$!
$ dirspec = F$PARSE(in_dirspec,,,"DEVICE") + -
F$PARSE(in_dirspec,,,"DIRECTORY")
$!
$DirLoop:
$ ON WARNING THEN GOTO DirLoop
$ nextfile = F$SEARCH("''in_dirspec'")
$ IF nextfile.EQS."" THEN GOTO EndDirLoop
$ filename = F$PARSE(nextfile,,,"NAME") + F$PARSE(nextfile,,,"TYPE") +
-
F$PARSE(nextfile,,,"VERSION")
$ filesize = F$FILE_ATTRIBUTES(nextfile,"EOF")
$ filedate = F$FILE_ATTRIBUTES(nextfile,"RDT")
$ sortdate = F$CVTIME(filedate)
$ wsf F$FAO("!47<!AS!> !6UL !23<!AS!>",filename,filesize,sortdate)
$ goto DirLoop
$EndDirLoop:
$ IF F$TRNLNM("schn").NES."" THEN CLOSE schn
$ SORT/KEY=(POS:57,SIZE:23'sortorder') 'sortspec' 'sortspec'2
$ wso "Directory ",dirspec
$ wso ""
$ FileTot = 0
$ SizeTot = 0
$ OPEN/READ schn 'sortspec'2
$ReadLoop:
$ READ/ERROR=End schn srec
$ FileTot = FileTot + 1
$ SizeTot = SizeTot + F$INTEGER(F$EXTRACT(49,6,srec))
$ wso srec
$ GOTO ReadLoop
$!
$End:
$ SET NOON
$ WSO ""
$ WSO F$FAO("Total of !UL file!1%C!%Es!%F, !UL block!1%C!%Es!%F", -
FileTot,SizeTot)
$ IF F$TRNLNM("schn").NES."" THEN CLOSE schn
$ IF F$SEARCH("''sortspec'*;*").NES."" THEN -
DELETE/NOLOG/NOCONFIRM 'sortspec'*;*
$ EXIT
$!--------------- END CUT HERE ------------------------
2) Create an "alias" in VMS:
LSLRT :== @my_device:[my_dir]LSLRT
...where "my_device:[my_dir]" is the location where you created the
LSLRT.COM file. For best results, also put this command in your
SYS$LOGIN:LOGIN.COM (".profile or .login in Unix"), so the "alias"
will work the next time you login.
3) To use:
LSLRT [-d] [filespec]
If you specify "-d", the sort order will be descending.
This is a quick'n'dirty DCL procedure, so USE AT YOUR OWN RISK!!! I tried
to make the best use of DCL (some error trapping and formatting) and also
to make this procedure readable and maintainable, but don't hold me or my
employer accountable for it use or misuse. (I hate the legal stuff!)
CAVEATS:
You may get some "file access conflict" errors if it looks at open files.
Sorry, I didn't have time to code around this. Also, if you get stars for
the filesize, you can increase the "6" in the "!6UL" for the filesize,
and decrease the "47" for the filesize in the same line. And, the date
displayed is the revision date. If you would like other dates displayed,
type "HELP LEX F$FILE ARG" and select the appropriate replacement argument
for the "filedate" symbol's call to F$FILE_ATTRIBUTE. And, finally, this
code won't handle stepping through some VMS structures like nested logicals
and the like.
That being said, I hope this helps! If I had time, I'd code one for ya in
BASIC or C...
Enjoy! :)
Rich Jesse System/Database Administrator
[EMAIL PROTECTED] Quad/Tech International, Sussex, WI USA
Owner of 3 VAXstations. :)
-----Original Message-----
Sent: Friday, November 16, 2001 04:00
To: Multiple recipients of list ORACLE-L
A user has asked me about identifying most recently created trace files on a
VMS system. I have shown him where they are and how to do a DIR/SIN=TODAY
command to get todays files.
However he was complaining that there was no equivalent on VMS to ls -lrt to
list all files oldest first.
I have looked at PIPE DIR *.TRC |SORT commands but you need a key and it is
not to obvious how to do it easily.
Does anybody know an easy way of doing it.
I have never needed to do it because I have always find the date parameter
to DIR to be sufficient but it would be nice to help a user out for a change
!!!
John
Oracle DBA
BTcellnet
* [EMAIL PROTECTED]
( 0113 388 6062 Desk
) 07713 066194 BT Mobile
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Jesse, Rich
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).