Re: Logfile name
briggs_at_encompasserve.org
Date: 02/28/05
- Next message: John Smith: "Re: OpenVMS Seminar in Toronto (2005-02-24) a few points"
- Previous message: briggs_at_encompasserve.org: "Re: Checking for "file open for write"."
- In reply to: David Gray: "Logfile name"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2005 10:18:01 -0600
In article <ej9u11lup726bgah3nipv153onhs4kfn4q@4ax.com>, David Gray <police@spamcop.net> writes:
> Hi all,
>
> From within a batch job how do I find out what the value of the /LOG
> qualifier was at submit time?
An oldie, but a goodie...
; PPF translate specified PPF logical name to file specification
; This is based on code posted on comp.os.vms by John Briggs
; on 19 Nov 1996, message-id <1996Nov19.110550@alpha.vitro.com>
; Modified by Jon Pinkley to accept a logical name so we can
; get the actual file name of a file opened by DCL.
; This also sets three local symbols, instead of only one.
;
; First delete local symbols PHY_FILE_NAME, ORG_FILE_NAME,
; and FID_FILE_NAME. These will be recreated when we can
; successfully determine them.
;
; PHY_FILE_NAME
; This is the unconcealed name of the file at the time
; it was opened. If it has been renamed, this will
; not be correct.
;
; PHY_FILE_NAME is set as follows:
; If it's a PPF, then do a $DISPLAY with nop=<noconceal>
; and save the resulting file name.
; If it is a record oriented device, (you can't trust
; fab$l_dev for this, you must ask $getdvi), instead
; of using the rsa returned by $display, use the
; nam$t_dvi value.
; (this is the name it had when it was opened.)
; if the device is a terminal, then save only the
; device name. Set FILE_NAME to the saved string.
; If it's not a PPF, exit with warning status CLI$_UNDFIL
; This is after all, meant to be used with PPF's
;
; ORG_FILE_NAME
; This is the concealed name of the file at the time
; it was opened. If it has been renamed, this will
; not be correct.
;
; ORG_FILE_NAME is set as follows:
; If it's a record oriented device
; set ORG_FILE_NAME to nam$l_dev
; otherwise
; do another $DISPLAY, this time displaying
; the concealed name, and set
; ORG_FILE_NAME to the concealed file name.
;
; FID_FILE_NAME is set as follows:
; If nam$l_fid is non zero
; determine the current file name by using lib$fid_to_name.
; Set FID_FILE_NAME to this value. Note that this file
; name will be correct if the file was renamed using the RENAME
; command (but not necessarily if the FID is entered
; multiple times).
;
; Usage: $ ppf :== $some_dir:ppf
; $ ppf [logical_name]
;
; if no logical is specified, then sys$output is assumed
; i.e. the following three are equivalent:
; $ ppf sys$output
; $ ppf
; $ run some_dir:ppf ! foreign command not necessary here
;
; The reason the this is the default is that it is very
; useful to allow a batch process to determine the exact
; filename and version of its log file.
;
; PPF can also be used to determine the version of file
; opened by DCL. Example follows:
; $ open/read foo sys$login:login.com
; $ ppf foo
; $ show symbol/local *_file_name
; FID_FILE_NAME = "DISK$USER1:[USERS.JON]LOGIN.COM;181"
; ORG_FILE_NAME = "ROOT$USERS:[JON]LOGIN.COM;181"
; PHY_FILE_NAME = "$4$DKA200:[USERS.][JON]LOGIN.COM;181"
; $ close/nolog foo
;
; example where file gets renamed while it is open
;
; $ open/write foo test.dat
; $ ppf foo
; $ sho sym /loc *_file_name
; FID_FILE_NAME = "DISK$JSCRATCH:[JON.PPF]TEST.DAT;1"
; ORG_FILE_NAME = "DISK$JSCRATCH:[JON.PPF]TEST.DAT;1"
; PHY_FILE_NAME = "$4$DKC204:[JON.PPF]TEST.DAT;1"
; $ ren test.dat; jons.data;100
; $ ppf foo
; $ sho sym /loc *_file_name
; FID_FILE_NAME = "DISK$JSCRATCH:[JON.PPF]JONS.DATA;100"
; ORG_FILE_NAME = "DISK$JSCRATCH:[JON.PPF]TEST.DAT;1"
; PHY_FILE_NAME = "$4$DKC204:[JON.PPF]TEST.DAT;1"
; $ close/nolog foo
.psect data,quad,noexe
$LNMDEF
$FABDEF
$NAMDEF
$DEVDEF
$DVIDEF
$CLIMSGDEF
.macro errchk, ?skip ; check for error
blbs r0, skip ; on success skip this
pushl r0 ; push offending status
calls #1, g^lib$stop ; and kill this thing
skip: .endm errchk ; and that's errchk!
fab: $FAB nam=nam
nam: $NAM rsa=buffer,-
rss=buffer_size,-
nop=<noconceal>
itemlist:
.word buffer_size
.word lnm$_string
.address buffer
.address file_name_desc
.long 0
.align quad
buffer: .blkb 255
buffer_size=.-buffer
.align quad
buffer1: .blkb 255
buffer1_size=.-buffer1
.align quad
buffer2: .blkb 16
buffer2_size=.-buffer2
.align quad
recdev: .blkl 1
dvirec: .long DVI$_REC
return_length:
.blkw 1
sysout: .ascid /SYS$OUTPUT/
tabnam: .ascid /LNM$FILE_DEV/
phynam: .ascid /PHY_FILE_NAME/ ; name file was originally opened with
orgnam: .ascid /ORG_FILE_NAME/ ; same as file_name, concealed
fidnam: .ascid /FID_FILE_NAME/ ; name determined by lib$fid_to_name
input: .long lnm$c_namlength ; make a descr for
.address 2$ ; lib$get_foreign
2$: .blkb lnm$c_namlength ; the buffer itself
file_name_desc:
.blkw 1
.word 0
.address buffer
fid_name_desc:
.blkw 1
.word 0
.address buffer1
dvi_name_desc:
.blkw 1
.word 0
.address buffer2
.psect code,exe
.entry MAIN,^m<>
; Get logical file name of PPF
pushal input ; set the length to the length returned
pushl #0 ; noprompt
pushal input ; write the rec'd data here
calls #3, g^lib$get_foreign ; get a command
errchk ; check for error
cmpw input, #0 ; no input logical specified?
bneq 5$
movc3 sysout,@sysout+4,@input+4 ; input = "SYS$OUTPUT"
movw sysout,input
5$:
; Delete the symbols we are going to set (ignore errors)
pushaq fidnam ; "FID_FILE_NAME"
calls #1,g^lib$delete_symbol
pushaq orgnam ; "ORG_FILE_NAME"
calls #1,g^lib$delete_symbol
pushaq phynam ; "PHY_FILE_NAME"
calls #1,g^lib$delete_symbol
; Translate specified logical name in LNM$FILE_DEV
pushal itemlist
pushl #0
pushaq input
pushaq tabnam
pushl #0
calls #5,g^sys$trnlnm
blbs r0,10$
brw 99$ ; error? bail
; Is it a PPF logical name?
10$: cmpw buffer,#^X001b ; Escape, null
beql 11$
brw 101$ ; it's not a PPF, quit
11$:
; Use $DISPLAY to get PPF file name
movw buffer+2,fab+fab$w_ifi
bisw2 #fab$m_ppf_ind,fab+fab$w_ifi
$display fab=fab ; first with non-concealed name
errchk ; check for error
; Determine if device is a record oriented device
; Note that network devices like node"user pass"::sys$login:login.com
; will have nam$t_dvi set to a null string. In this case, just
; treat it like a non-record oriented device. We will handle
; the lack of a FID at a later time.
; copy the nam$t_dvi name into the dvi_name string
movzbw nam+nam$t_dvi,dvi_name_desc
bneq 12$
brw 20$ ; must be a decnet device name
12$:
movc3 dvi_name_desc,nam+nam$t_dvi+1,@dvi_name_desc+4
pushal recdev ; boolean for record oriented device
pushaq dvi_name_desc ; device name
pushl #0 ; channel not specified
pushal dvirec ; address containing DVI$_REC
calls #4,g^lib$getdvi
errchk
tstl recdev ; if record oriented device
beql 20$ ; then skip the following
; here we have a record oriented device. Directory and
; file names really don't make a lot of sense.
; set PHY_FILE_NAME to nam$t_dvi and
; ORG_FILE_NAME to nam$l_dev
; leave FID_FILE_NAME undefined
pushaq dvi_name_desc
pushaq phynam
calls #2,g^lib$set_symbol
errchk
; copy the nam$l_dev name into the file_name string
movzbw nam+nam$b_dev,file_name_desc
movc3 file_name_desc,@nam+nam$l_dev,@file_name_desc+4
pushaq file_name_desc
pushaq orgnam
calls #2,g^lib$set_symbol
errchk
brw 99$
; Stuff file name length into descriptor
20$: movzbw nam+nam$b_rsl,file_name_desc
; The file name is all set up in file_name_desc
; Stuff it into the DCL symbol 'PHY_FILE_NAME'
30$: pushaq file_name_desc
pushaq phynam
calls #2,g^lib$set_symbol
errchk
; Use $DISPLAY to get PPF file name concealed
bicb2 #<nam$m_noconceal>, nam+nam$b_nop
$display fab=fab
blbs r0,40$
ret ; If it fails, exit
; Stuff file name length into descriptor
40$: movzbw nam+nam$b_rsl,file_name_desc
; The file name is all set up in file_name_desc
; Stuff it into the DCL symbol 'ORG_FILE_NAME'
pushaq file_name_desc
pushaq orgnam
calls #2,g^lib$set_symbol
errchk
; Now grab the FID from the NAM block and convert
; it to a filename using LIB$FID_TO_NAME, then
; stuff it into the DCL symbol 'FID_FILE_NAME'
; we're going to use buffer1, set the length in
; the descriptor to buffer_size
movab buffer1,fid_name_desc+4 ; make sure we have it
movzbw #buffer1_size, fid_name_desc
; we are going to reuse the descriptor for the
; nam$t_dvi counted string
movzbw nam+nam$t_dvi, file_name_desc
beql 99$ ; no FID, bail out
movab nam+nam$t_dvi+1, file_name_desc+4
pushaw return_length
pushaq fid_name_desc
pushaw nam+nam$w_fid
pushaq file_name_desc
calls #4,g^lib$fid_to_name
errchk
; Stuff file name length into descriptor
60$: movzbw return_length,fid_name_desc
; The file name is all set up in file_name_desc
; Stuff it into the DCL symbol 'FID_FILE_NAME'
70$: pushaq fid_name_desc
pushaq fidnam
calls #2,g^lib$set_symbol
99$: ret
101$: movl #CLI$_UNDFIL,r0
brb 99$
.end main
- Next message: John Smith: "Re: OpenVMS Seminar in Toronto (2005-02-24) a few points"
- Previous message: briggs_at_encompasserve.org: "Re: Checking for "file open for write"."
- In reply to: David Gray: "Logfile name"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|