Operating System - OpenVMS
1748246 Members
3653 Online
108760 Solutions
New Discussion юеВ

Re: Writing a dcl script to delete files

 
SOLVED
Go to solution
vmsserbo
Super Advisor

Writing a dcl script to delete files

We have backed up all the files and will no longer require these large files to be on the sites.

I would like to delete all the TEAM_*_ALL.*;* all the LAWSUIT_CALIF_EXT*.DAT;* and all the LANE_CALIF_EXT*.DAT;* files across all sitesтАЩin the PROD_RMS directories.

Can someone write up a simple script for this, I would appreciate it!

Thanks!





9 REPLIES 9
Aaron Sakovich
Super Advisor
Solution

Re: Writing a dcl script to delete files

Presuming your Prod_RMS directories are at the top level of your disks (adjust accordingly if not):

$ loop:
$ disk = f$device(,"disk")
$ if disk .nes. "" then if f$getdvi(disk,"Mnt")
$ then
$ delete 'disk'[Prod_RMS...]team_*_all.*;*
$ delete 'disk'[Prod_RMS...]lawsuit_calif_ext*.dat;*
$ delete 'disk'[Prod_RMS...]lane_calif_ext*.dat;*
$ goto loop
$ endif
Jan van den Ende
Honored Contributor

Re: Writing a dcl script to delete files

Milse, Aaron,


$ loop:
$ disk = f$device(,"disk")
$ if disk .nes. "" then if f$getdvi(disk,"Mnt")
$ then
$ delete 'disk'[Prod_RMS...]team_*_all.*;*
$ delete 'disk'[Prod_RMS...]lawsuit_calif_ext*.dat;*
$ delete 'disk'[Prod_RMS...]lane_calif_ext*.dat;*
$ goto loop
$ endif


If this sctipt would encounter a foreign mounted disk, a shadow set member, a CD drive, a write-locked drive, ..., you would finish without doing all disks.

I suggest a slight modification.


$ loop:
$ disk = f$device(,"disk")
$ if disk .nes. ""
$ then
$ if f$getdvi(disk,"Mnt")
$ then
$ set noon ! proceed if DELETE impossible for any reason
$ delete 'disk'[Prod_RMS...]team_*_all.*;*
$ set noon ! set again (undone at first fai;, but then this one also likely to fail
$ delete 'disk'[Prod_RMS...]lawsuit_calif_ext*.dat;*
$ set noon
$ delete 'disk'[Prod_RMS...]lane_calif_ext*.dat;*
$ goto loop ! seek next disk
$ endif
$ endif

Instead of SET NOON in a decent procedure I would test the various statusses a disk could be in that would lead to error, but this looks like a one-timer, and then the quick-and-dirty is the cheaper solution.


hth

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
vmsserbo
Super Advisor

Re: Writing a dcl script to delete files

Actually,

On all nodes if I do dir prod_rms:TEAM_*_ALL.*;*

Now the prod_rms is a log pointing to the actual device where prod_rms directory is located. The files are there.
Aaron Sakovich
Super Advisor

Re: Writing a dcl script to delete files

oh, a logical? then it's really trivial...

$ Set NoOn
$ Delete Prod_RMS:team_*_all.*;*
$ Delete Prod_RMS:Lawsuit_Calif_Ext*.dat;*
$ Delete Prod_RMS:Lane_Calif_ext*.dat;*

I don't think I'd even call that a script... ;^)
vmsserbo
Super Advisor

Re: Writing a dcl script to delete files

That's what I thought Thanks everyone!
Thomas Ritter
Respected Contributor

Re: Writing a dcl script to delete files

The file names indicate potentially sensitive data.

Perhaps a "$ delete/erase" is in order.

From vms help

DELETE

file

/ERASE

/ERASE
/NOERASE (default)

When you delete a file, the area in which the file was stored is
returned to the system for future use. The data that was stored
in that location still exists in the system until new data is
written over it. When you specify the /ERASE qualifier, the
storage location is overwritten with a system specified pattern
so that the data no longer exists.


Also does the disk have highwater marking enabled ?

SET

VOLUME

/HIGHWATER_MARKING

/HIGHWATER_MARKING
/NOHIGHWATER_MARKING

Determines whether the file highwater mark (FHM) volume attribute
is set. The FHM attribute guarantees that a user cannot read data
that was not written by the user. Applies to Files-11 On-Disk
Structure Level 2 (ODS-2) and 5 (ODS-5) volumes only.


Why mention this ? DFU has a facility to "UNDELETE" files. We deal with sensitive data and when we delete the files, they are deleted and stay deleted !

my aus 0.02
Peter Zeiszler
Trusted Contributor

Re: Writing a dcl script to delete files

I would also suggest am image backup of the files prior to deleting. Also keep a log file of all of the files removed. Just in case.
John Travell
Valued Contributor

Re: Writing a dcl script to delete files

How many files are there in total ?
If a lot, it may well be worth writing a script to delete them in reverse order.
When VMS deletes a file it shuffles all of the alphabetically higher directory entries down. This makes for a fast read of the directory next time round, but if the directory file itself is large the shuffle can take a while, and is repeated for every file deleted.
Doing the deletes in reverse order reduces (or even eliminates) that shuffling as there are fewer, if any, directory entries above the deleted file to shuffle.
Karl Rohwedder
Honored Contributor

Re: Writing a dcl script to delete files

There are some procedures floating around for
reverse deletion of large number of files.
I attach mine to give you an idea.

regards Kalle