1752761 Members
4987 Online
108789 Solutions
New Discussion юеВ

Re: Vms DCL Code

 
SOLVED
Go to solution
Wim Van den Wyngaert
Honored Contributor

Re: Vms DCL Code

I would also test the miniumum. f$cvt("--1-00") is also a valid syntax.

Wim
Wim
Wim Van den Wyngaert
Honored Contributor

Re: Vms DCL Code

And as I read your code, it should prompt you again (Enter # of Days>").

Wim
Wim
Hein van den Heuvel
Honored Contributor

Re: Vms DCL Code

>> Shouldn't it just exit or prompt me to put in the right # of days again?

Yes, if you made the edit correctly, then it should.
See my early example how to use a single IF with OR clause if desired.

>> it just hangs there

Are you sure? Dcl scripts do not 'just sit there'.
Check at least with control-T or SET VERIFY
(control-Y, $set verify, $continue).



Please note MANY inefficiencies and oddities in the script.

imho that "f$cvtime("-''date'-00"
is better written withotu the "00". That just confuses.

Instead of worrying about spaces in the dates before the 10'th you may want to search using ... /MATCH=AND "Start: ", " ''thedate'"

IF you are going to unconditionally append the search out to a file, then why not have search put it there directly?
Instead of

$create 'outf'
$loop:
$sea/out=x.tmp
$appen x.tmp 'outf'
:
$if .not.done then goto loop

use:

$create 'outf'
$open/append outf 'outf'
$loop:
$sea/out=outf
:
$if .not.done then goto loop
$close outf

But most importantly... don't loop through the file over and over!
You might want to open it with DCL, or an other language, check each record. If it has "Start:", then check the date.

Personally I would use perl.
I'll stick in an example, because the date handling might be tricky for a first time.

Usage:

$perl date-filter.pl stats_dir:autostat.dat 123 > 'outf'

#---- date-filter.pl ----
use strict;
use Time::Local;

my $file = shift or die "Please provide file to search";
my $days = shift or die "Please provide a number of daqys to look for";
my ($sec,$min,$hour,$mday,$mon,$year) = localtime();
my $cutoff = timelocal(0,0,0,$mday,$mon,$year) - $days*86400;

open FILE, "<$file" or die "Could not open search file $file\n$!";
while () {
if (/(\d+)-(\w+)-(\d+)/) {
my $n = index(" JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC", $2)/3;
print if $cutoff < timelocal(0,0,0,$1,$n-1,$3-1900);
}
}
#-------------------------------

Enjoy,
Hein.
John Travell
Valued Contributor

Re: Vms DCL Code

Without checking what else your code does, I cannot fully answer why it hangs for you. On my V8.3 machine the following trivial mod of your code works as expected.
$ maxdays = 365
$detail:
$ read/prompt="ENTER # OF DAYS (up to ''maxdays') > " sys$command date
$ if f$type(date) .nes. "INTEGER" then goto detail
$ if date .gt. maxdays then goto detail

You need to replicate this at 'Summary:', but other than that I cannot see why you have any problem with the code.
John Travell
Valued Contributor

Re: Vms DCL Code

Darn, Hein's response was not there when I started to reply... Pass on mine, Hein did a much better job...
JT:
Hoff
Honored Contributor

Re: Vms DCL Code

[[[Yes, When I put in 31 days for the max and type in 32 it just hangs there? Shouldn't it just exit or prompt me to put in the right # of days again?]]]

Well, only if you coded the DCL to do that, actually.

DCL does what you tell it to do, within its various limits. DCL is certainly arcane, but it's also among the company of most other languages in lacking any sort of magical DWIM (do what I mean) powers. You gotta code it, or it just won't happen.

Now to see what is happening here with your hang, use the verification mechanism; straight SET VERIFY and invoke, or use something akin to:

$ oldvfy = f$verify(f$trnnm("BACKUP_DEBUG"))
[stuff]
$common_exit:
$ vfy = f$verify(oldvfy)
$ exit

to allow you to selectively enable debug with a logical name. Then see what's wedging.

Based on a quick look, that DCL code is laced with design errors and with some subtle restrictions. It's easy for filenames to collide, for instance.

As has been stated, the processing of the input string is best updated. I'd probably swap from:

$detail:
$ read/prompt="ENTER # OF DAYS > " sys$command date
$ if f$type(date) .nes. "INTEGER" then goto detail

over to -- and note I changed "date" to "days" here, which will require changes downstream -- the following:

$detail:
$ read/prompt="ENTER # OF DAYS > " sys$command days
$ days = f$integer(days)
$ if (days .le. 0) .or. (days .gt. 365) then goto detail

This:

$ search prod_admin:backup.log,backup.sav;*

looks broken. Searching the binary saveset? Really?

This:

/output=addm0700_backup_save.tmp

can collide.

This:

$ if f$search("''addm0700*.tmp;'") .nes. "" then purge/nolog 'addm0700*.tmp;';*
$ if f$search("''addm0700*.tmp;'") .nes. "" then delete/nolog 'addm0700*.tmp;';*

looks broken

I'd probably put the days prompt code in a subroutine, since it looks common.)

This:

$ Set proc/priv=all

implies this is some sort of a menu. And f$setprv() is more common. And enabling all privileges at the top of the DCL is just asking for something (else) to get corrupted or deleted. (The good news for those so included: unless that login thing is marked CAPTIVE, full privileges are easily available.)

And I'd add an /ERROR and/or /END_OF_FILE on the READ, to allow a graceful path out if something on the input messes up. Or if the user uses ^Z to try to punt the operation.

I'm not at all certain if my DCL book is in or out of print. It seems to wink in and out of publication status; AFAIK, it's still available as a demand-print book.

Stephen Hoffman
HoffmanLabs LLC