- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- SUbtracting in OpenVMS
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 03:29 AM
09-20-2010 03:29 AM
I am writing a COM to rename a group of files which satisfy the below condition. The File name has the current date and time
Example: 20100919103344
If the difference between the current date (20100920) and the file date (20100919) is greater than 1, then i need to do certain steps.
I tried this but it is not working as expected.
$file_name = "V2B_20100919103344.TXT"
$file_name = "V2B_20100919103344.TXT_TEMP"
$
$SH SYM file_name
FILE_NAME = "V2B_20100919103344.TXT_TEMP"
$file_date = f$extract(4,8,''file_name)
$SH SYM file_date
FILE_DATE = "20100919"
$CUR_DAT = F$CVTIME(,,"DATE") - "-" - "-"
$SH SYM CUR_DAT
CUR_DAT = "20100920"
$
$FINAL = (CUR_DAT - FILE_DATE)
$SH SYM FINAL
FINAL = "20100920"
Please advice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 03:52 AM
09-20-2010 03:52 AM
Re: SUbtracting in OpenVMS
Dan
============================================
$file_name = "V2B_20100919103344.TXT"
$file_name = "V2B_20100919103344.TXT_TEMP"
$!
$SH SYM file_name
$file_date = f$extract(4,8,''file_name)
$SH SYM file_date
$CUR_DAT = F$CVTIME(,,"DATE") - "-" - "-"
$SH SYM CUR_DAT
$!
$ c=f$integer("''cur_dat'")
$ f=f$integer("''file_date'")
$FINAL = (c - f)
$SH SYM FINAL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 06:18 AM
09-20-2010 06:18 AM
Re: SUbtracting in OpenVMS
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 12:56 PM
09-20-2010 12:56 PM
Re: SUbtracting in OpenVMS
Why subtract? Your requirement
"If the difference between the current date"
_any_ difference will be 1 day or more.
So instead of :
- $FINAL = (CUR_DAT - FILE_DATE)
Use a string compare like:
- $IF CUR_DAT .GTS. FILE_DATE .......
Enjoy,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 02:10 PM
09-20-2010 02:10 PM
Re: SUbtracting in OpenVMS
When DCL sees what appears to be an arithmetic expression containing only "+" and "-" it tries to work out if this is an INTEGER operation or a STRING operation, depending on the apparent types of the operands. In this case CUR_DATE is determined to be STRING, so the operation is STRING. Since the subtrahend is not a substring of the minuend, the result is the minuend.
You need to be very careful with these operators, to make sure DCL understands your intent. Sometimes you need to use F$INTEGER to force an operand to be interpreted as INTEGER or F$STRING to force it to be STRING.
In this case I'd go with Hein and use a comparison. Note that there you also need to be explicit about data type "GTS" for string and "GT" for integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 05:04 PM
09-20-2010 05:04 PM
Re: SUbtracting in OpenVMS
$ yest_date = F$CVTIME("","COMPARISON","DATE") - "-" - "-"
(The above gives 20100921 when I run it because here it's already 21 Sep here.)
Just compare yest_date to the first 8 characters of your filename string.
It's not clear if you want to rename the files but this would be the simplest because you wouldn't need to check if the files were created earlier than yesterday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2010 06:58 PM
09-20-2010 06:58 PM
Re: SUbtracting in OpenVMS
Thanks a lot for your replies.
I will be trying today with all of your valuable inputs..
Really thanks a lot..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 02:02 AM
09-22-2010 02:02 AM
Re: SUbtracting in OpenVMS
I have a problem now.
Consider this Example:
The current date is 20101001(October 1st 2010). The File date is 20100930.
I went with subtracting them as an integer. But i need the value to be 1. If i subtract, it gives the putput as 71.
Please Help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 03:02 AM
09-22-2010 03:02 AM
Re: SUbtracting in OpenVMS
Is there no way you can do this using the f$delta_time lexical.
F$DELTA_TIME
Returns the time difference between a given start and end time.
The end time must be the same as or later than the start time.
Format
F$DELTA_TIME(start-time,end-time)
Times are supplied as "Absolute", so use f$cvtime to convert FILE_DATE back to absolute, Set CUR_DATE to f$cvtime(,"ABSOLUTE","DATE").
f$delta will return the difference as a Delta time. From which you extract the "day" component to test.
It certainly avoids having to worry about days-in-month.
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 03:39 AM
09-22-2010 03:39 AM
Re: SUbtracting in OpenVMS
Even if You take f$integer() of the dates, don't think the difference of the two integers is the number of days between two dates!
Example:
20101001-20100901 = 100, not 30 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 04:00 AM
09-22-2010 04:00 AM
Re: SUbtracting in OpenVMS
I have the file_date like this 20100930.
How will i convert it to absolute time ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 04:16 AM
09-22-2010 04:16 AM
Re: SUbtracting in OpenVMS
I need to find out all the files from a certain logical, which are older than 1 day from the current date and rename them.
The file Format which we have is %%_yyyymmddhhmmss.%%%
I get the FILE_DATE as "20100930"
How can i convert it into absoulte date ?
I tried the below:
$CUR_DATE = f$cvtime(,"ABSOLUTE","DATE")
$
$YEST = f$cvtime("YESTERDAY","ABSOLUTE","DATE")
$
$
$SH SYM CUR_DATE
CUR_DATE = "22-SEP-2010"
$
$SH SYM YEST
YEST = "21-SEP-2010"
$
$DAYS = F$DELTA_TIME (YEST,CUR_DATE)
$
$SH SYM DAYS
DAYS = " 1 00:00:00.00"
$
How can i extract DAY component from the variable DAYS ?
Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 04:30 AM
09-22-2010 04:30 AM
Re: SUbtracting in OpenVMS
Dan
==================================
$ a=f$cvtime("yesterday")
$ yyyy=f$extract(0,4,a)
$ mm=f$extract(5,2,a)
$ dd=f$extract(8,2,a)
$ srch_string=yyyy+mm+dd
$ dir/before=yesterday *'string'*
===================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 04:31 AM
09-22-2010 04:31 AM
Re: SUbtracting in OpenVMS
I have the file_date like this 20100930.
How will i convert it to absolute time ?
Try this .COM file:
$!
$ cdt=p1
$ y=f$extract(0,4,cdt)
$ m=f$extract(4,2,cdt)
$ d=f$extract(6,2,cdt)
$mn="NULL,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,"
$ nm=f$integer(m)
$! if (m.klt.1).or.(M>12) THEN GOTO ERR
$ mon=f$element(nm,",",mn)
$ vmsdate=d+"-"+mon+"-"+y
$ show symbol vmsdate
$ exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 05:10 AM
09-22-2010 05:10 AM
Re: SUbtracting in OpenVMS
As usual, "What problem are you trying to solve" is important info.
>>>
I need to find out all the files from a certain logical, which are older than 1 day from the current date and rename them.
<<<
In VMS, this info is directly available:
$ Credat = f$file_attribute(filename,"CDT")
... and do the date-handling from there.
But even more directly if you want to rename them:
$ RENAME filename newname /BEFORE=YESTERDAY.
... if you need to retain (parts of) the file spec, then there are really nice tricks with wildcarding, or if you need more sofisticated manipulations, with f$parse.
But YOU have to tell us WHAT you need.
hth
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 05:12 AM
09-22-2010 05:12 AM
Re: SUbtracting in OpenVMS
Original:
$ srch_string=yyyy+mm+dd
$ dir/before=yesterday *'string'*
Corrected:
$ srch_string=yyyy+mm+dd
$ dir/before=yesterday *'srch_string'*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 06:31 AM
09-22-2010 06:31 AM
Re: SUbtracting in OpenVMS
>> How will i convert it to absolute time ??
Just like you always when you chewed of more than you can handle: A couple of bytes at a time
Joseph give a fine bit of parsing and reconstructing using F$ELEMENT. I like and often use that. But then you have to glue in the dashes.
So for this case I prefer F$EXTRACT and ditch the intermediate variable... those are for wimps!
$ vmsdate = f$extract(6,2,cdt) + -
f$extract( 4 * f$extract(4,2,cdt), 5, "NULL-JAN-FEB-MAR-APR-MAY-JUN-JUL-AUG-SEP-OCT-NOV-DEC-") + -
f$extract(0,4,cdt)
$
$ write sys$output cdt, " = ", vmsdate, " = ", f$cvtime(vmsdate,,"DATE")
>> I need to find out all the files from a certain logical, which are older than 1 day from the current date and rename them.
Ah! Here is what we really want to to (Jan!)
Is that a simple rename like directory, extension or name only, or complex replacing pieces of string in the name?
If it is complex rename, then you may want to consider a perl 'one-liner'
Just for fun....
First you test with 'print qq'
$ perl -le "for (
for (
if ( -M > 1 ) ... Modification data older than 1.0 days?
$old = $_; ... Remember the old name
s/V2B/done/; ... Substitute a piece of string in $_
print qq($old, $_ ) ... print what rename details.
Now make it real by just replacing "print qq" with "rename"
$ perl -le "for (
This assumes that the file modification date matched the file name, which may be a stretch
And it assumes that you really wanted more than 24 hours = 1.0 days old, not just 'yesterday'.
If you want yesterday use DIR/BEF=YES.
Perl can of course also suck on that piece of time string in the filename and turn it into a real time.
Just for your entertainment....
One of many ways to pick apart the string:
$ perl -le "($y,$m,$d) = unpack(q(a4a2a2),q(20100930)); print qq(y=$y m=$m d=$d)"
y=2010 m=09 d=30
And now turn that into a time (seconds since 1-jan-1970, 86400 per day) and back:
$ perl -le "use Time::Local; ($y,$m,$d) = unpack q(a4a2a2),q(20100930); print scalar localtime timelocal(0,0,0,$d,$m-1,$y)"
Thu Sep 30 00:00:00 2010
Hope this helps some,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 07:01 AM
09-22-2010 07:01 AM
Re: SUbtracting in OpenVMS
I achieved the conversion of absoulte date from the string by using the below command:
$file_date="20100922"
$ADATE = F$CVTIME(f$extract(0,4,file_date)-f$extract(5,2,file_date)-f$extract(7,2,file_date), "ABSOLUTE", "DATE")
$sh sym adate
ADATE = "22-SEP-2010"
$
$
Anyway thanks for all your comments..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 07:10 AM
09-22-2010 07:10 AM
Re: SUbtracting in OpenVMS
Try 20100830.
You ended up substracting pieces of string from each other resulting in '010'.
That was used as the HOUR in the time defaulting the rest to "TODAY" and the time being discarded by the explicit "DATE" request.
Watch:
$ write sys$output f$extract(0,4,file_date)-f$extract(5,2,file_date)-f$extract(7,2,file_date)
010
$ write sys$output F$CVTIME(010,"ABSOLUTE")
22-SEP-2010 10:00:00.00
Cheers,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 07:14 AM
09-22-2010 07:14 AM
Re: SUbtracting in OpenVMS
Fine if You are happy.
In fact what it gives You is the date of today 10 O'Clock.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 07:38 AM
09-22-2010 07:38 AM
Re: SUbtracting in OpenVMS
Thanks...
I am trying it for other dates.
Joseph,
I am not able to seee the query u used.... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 08:16 AM
09-22-2010 08:16 AM
Re: SUbtracting in OpenVMS
TRY it.
And then, if anything still is unclear, detail that.
Proost.
Have one on me.
jpe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 08:32 AM
09-22-2010 08:32 AM
Re: SUbtracting in OpenVMS
sorry... was lil busy...
actually in your idea, it is taking the created date :-( so, here the jobs run for around 8 hours continuously.
So, the file date can be 20100920120023
but the create date will be after 20th..
So, that will not workout for me...
I need the file date and not the file create date ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2010 08:41 AM
09-22-2010 08:41 AM
Re: SUbtracting in OpenVMS
>>>
So, the file date can be 20100920120023
but the create date will be after 20th..
So, that will not workout for me...
I need the file date and not the file create date ...
<<<
Please be clear about that!
The moment you initiate a file (at the start of the job I assume?) is the CreateDateTime (CDT). The moment you close such file (near the end of the job?) will be RevisionDateTime (RDT) -- but that gets updated every time you change ANYTHING in the file OR ITS DESCRIPTION.
If it is more complicated than that, please be clearer.
Proost.
Have one on me.
jpe