various tips and tricks

Post Reply

Topic author
gl
Member
Posts: 7
Joined: Fri Jul 10, 2020 11:29 am
Reputation: 0
Status: Offline

various tips and tricks

Post by gl » Sun Feb 02, 2025 10:19 am

Hello

I guess we all have similar code, but just in case

1) when I launch a batch, I want to see what it does at the beginning

I have a symbol last

last :== @sys$login:last

with last.com containing

$ if $entry.nes."" then sh proc/cont/id='f$getqui("display_entry","job_pid",$entry)'

of course, it can also work for any batch number if you replace $entry by any batch number

we suppose that the batch runs on the same Cluster node, of course

2) when awk was available as
awk :== $ SYS$COMMON:[SYSHLP.EXAMPLES.TCPIP.SNMP]GAWK.EXE

I had a file

g.awk containing

$NF ~ /.LOG;[0-9]+$/ {print $NF ;
system ("type/tail " $NF ) }

and a file typlog.com containing
$ ! test if the pid exists
$ set mess/nofac/nosev/noide/notext
$ show proc/ide='p1 /out=nla0:
$ if .not.$status then exit
$ set mess/fac/sev/ide/text
$ pipe wr sys$output "sh proc/id=''P1'/chan" | ana/sys | awk/input=sys$login:g.awk sys$pipe
$ exit

so that

@ typlog 'pid'

found the .log file opened by the process and did a

ty/tail on that file

3) when a Decnet or CFT copy is huge, we like to get an idea of the ETA

I use that code, it needs the SDA extension procio

of course, instead of all that DCL, a SDA extension would be a better way


$ set noon
$ say :== write sys$output
$ set mess/nofac/nosev/noide/notext
$ IF p1.EQS."MON" THEN GOTO MON
$ show proc/ide='p1 /out=nla0:
$ if .not. '$status
$ then
$ say "pid ''P1' absent"
$ exit
$ endif
$ set mess/fac/sev/ide/text
$ pipe say "sh proc/id=''P1'/rms=rab" | ana/sys | sea sys$pipe RFA | -
(read sys$pipe in ; v = f$extract(0,8,f$elem(2,":",f$edit (in,"collapse") ) ) ; v="%X"+v ; -
say &v," blocks transferes en " -
; say f$edit(f$delta(f$getjpi("''P1'","logintim"),f$time()),"trim") ; def/job/nolog v &v)
$ IF p1.EQS."MON" THEN GOTO MON
$ self=F$PARSE(";",F$ENVIRONMENT("PROCEDURE"))
$ IF p1.EQS."" THEN p1=5
$ pid :== p1
$ pipe (write sys$output "set proc/id=''P1'" ; write sys$output "procio p") |-
ana/sys | @'self' MON
$ EXIT
$
$ MON:
$ OPEN/READ in SYS$PIPE:
$ Loop: READ/END=fin in line
$ if F$Extract(0,56,line).nes."--------------------------------------------------------" then goto loop
$ READ/END=fin in line
$ fic = f$elem(3," ",f$edit(line,"compress"))
$ taille == f$file("''fic'","ALQ")
$ wr sys$output f$fao("!8AS!60AS!14UL!12AS","fichier ",fic,taille," blocks ")
$ vv == 'f$trnlnm("v")'
$ wr sys$output f$fao("!80**")
$ goto loop
$ fin:
$ close in
$ sh lo logintim
$ call percent 'vv' 'taille'
$ say f$edit(f$delta(f$getjpi("''pid'","logintim"),f$time()),"trim")
$ call eta
$ exit
$ percent: subroutine
$ maxint = %x7fffffff
$ p1 = f$integer (p1)
$ p2 = f$integer (p2)
$ if p1 .gt. maxint/100
$ then
$ multiplier = 1
$ divisor = p2/100
$ else
$ multiplier = 100
$ divisor = p2
$ endif
$ if p1 + divisor/2 .lt. 0
$ then
$ rounding = 0
$ else
$ rounding = divisor/2
$ endif
$ percent == (p1 * multiplier + rounding ) /divisor
$ wr sys$output f$fao("!2SL!2AS",percent," %")
$ endsubroutine
$ eta: subroutine
$ duree = f$getjpi("''pid'","logintim")
$ sh symb duree
$ sec = f$cvtime(duree,"delta","SECOND")
$ sh symb sec
$ min = f$cvtime("''duree'","delta","MINUTE")
$ sh symb min
$ hour = f$cvtime("''duree'","delta","HOUR")
$ sh symb hour
$ day = f$cvtime("''duree'","delta","DAY")
$ sh symmb day
$ tot_sec = sec + (60 * min) + (3600 * hour) + (86400* day)
$ say tot_sec
$ endsubroutine

User avatar

arne_v
Senior Member
Posts: 637
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: various tips and tricks

Post by arne_v » Sun Feb 02, 2025 11:11 am

Code: Select all

$ clean :== pipe purge ; rename *.* /excl=*.*.1 *.*.1
Arne
arne@vajhoej.dk
VMS user since 1986

User avatar

cct
Master
Posts: 278
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: various tips and tricks

Post by cct » Sun Feb 02, 2025 2:22 pm

arne_v wrote:
Sun Feb 02, 2025 11:11 am

Code: Select all

$ clean :== pipe purge ; rename *.* /excl=*.*.1 *.*.1
I think you need *.*;1
:D
Chris Townley
VMS Ambassador

User avatar

arne_v
Senior Member
Posts: 637
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: various tips and tricks

Post by arne_v » Sun Feb 02, 2025 4:14 pm

cct wrote:
Sun Feb 02, 2025 2:22 pm
arne_v wrote:
Sun Feb 02, 2025 11:11 am

Code: Select all

$ clean :== pipe purge ; rename *.* /excl=*.*.1 *.*.1
I think you need *.*;1
:D
:-)

.version works as well as ;version and ; has a another meaning with PIPE so I chose .version !
Arne
arne@vajhoej.dk
VMS user since 1986

User avatar

cct
Master
Posts: 278
Joined: Sat Aug 15, 2020 9:00 am
Reputation: 0
Location: Cambridge, UK
Status: Offline

Re: various tips and tricks

Post by cct » Sun Feb 02, 2025 5:28 pm

arne_v wrote:
Sun Feb 02, 2025 4:14 pm
cct wrote:
Sun Feb 02, 2025 2:22 pm
arne_v wrote:
Sun Feb 02, 2025 11:11 am

Code: Select all

$ clean :== pipe purge ; rename *.* /excl=*.*.1 *.*.1
I think you need *.*;1
:D
:-)

.version works as well as ;version and ; has a another meaning with PIPE so I chose .version !
Blimey, that'd a new one on me
I am most surprised, as with SET PROCESS /PARSE_STYLE=EXTENDED it could mean different things
Chris Townley
VMS Ambassador

User avatar

arne_v
Senior Member
Posts: 637
Joined: Fri Apr 17, 2020 7:31 pm
Reputation: 0
Location: Rhode Island, USA
Status: Offline
Contact:

Re: various tips and tricks

Post by arne_v » Sun Feb 02, 2025 7:31 pm

cct wrote:
Sun Feb 02, 2025 5:28 pm
arne_v wrote:
Sun Feb 02, 2025 4:14 pm
cct wrote:
Sun Feb 02, 2025 2:22 pm


I think you need *.*;1
:D
:-)

.version works as well as ;version and ; has a another meaning with PIPE so I chose .version !
Blimey, that'd a new one on me
I am most surprised, as with SET PROCESS /PARSE_STYLE=EXTENDED it could mean different things
There are some rules.

https://docs.vmssoftware.com/guide-to-o ... PE_VERSION

has some examples.

Added in 1 minute 35 seconds:
But yes - period instead of semicolon for version is about as much used as angle brackets instead of square brackets for directory.

I always use semicolon unless I have a reason to use period. PIPE is one of the exceptions.

Added in 10 minutes 59 seconds:
Note that I actually think PIPE can distinguish between version semicolon and command separator semicolon based on spaces. But I like the clarity of only one type of semicolon.
Arne
arne@vajhoej.dk
VMS user since 1986

Post Reply