Computing.Net > Forums > OpenVMS > VMS script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VMS script

Reply to Message Icon

Name: singaporedeb
Date: November 5, 2003 at 01:37:05 Pacific
OS: n/a
CPU/Ram: n/a
Comment:

I have to write a script in a command file to delete some files which are older than 14 days than the date entered by user. The problem is that the dates to delete are not dependant on the date of creation but by the date given in the filename e.g. DEB_31082002.FIL. So in this case I would want to delete anything older than 17th August 2002. This is very tricky since I have to consider both month and year rollovers. Any ideas?




Sponsored Link
Ads by Google

Response Number 1
Name: ME
Date: November 9, 2003 at 09:32:25 Pacific
Reply:

Not so difficult if you let VMS calculate the boundary. A basic commandfile would look something like :

$!
$! ask the date in VMS format DD-MMM-YYYY
$!
$ read sys$command /prompt="date " askdate
$ deldate = f$cvtime("''askdate'-14-","COMPARISON","DATE")
$!
$! Loop through files looking for candidates
$!
$findfile:
$ fullname = f$search("deb*.fil;*")
$ if fullname .eqs. "" then goto endfiles
$ filename = f$parse(fullname,,,"NAME","SYNTAX_ONLY")
$ filedate = f$extract(8,4,filename) + "-" + -
f$extract(6,2,filename) + "-" + -
f$extract(4,2,filename)
$ sh sym filedate
$ if filedate .lts. deldate
$ then
$ write sys$output "This file will be deleted ", filename
$! delete /log 'fullname'
$ endif
$ goto findfile
$endfiles:
$ exit


0

Response Number 2
Name: atst
Date: January 8, 2004 at 07:46:45 Pacific
Reply:


Thanks. I use it.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to OpenVMS Forum Home


Sponsored links

Ads by Google


Results for: VMS script

How to recieve arguments from user www.computing.net/answers/openvms/how-to-recieve-arguments-from-user/596.html

porting of shell script to DCL COM scrip www.computing.net/answers/openvms/porting-of-shell-script-to-dcl-com-scrip/19.html

script needed www.computing.net/answers/openvms/script-needed/510.html