Operating System - OpenVMS
1820027 Members
3495 Online
109608 Solutions
New Discussion юеВ

Re: Change/Modify VMS file creation date

 
SOLVED
Go to solution
Kyle Snavely_1
Advisor

Change/Modify VMS file creation date

Is it possible to change a file creation date using tools native to VMS? The only reference I've seen is to an old FILE utility from Joe Meadows.

I didn't see anything that looked like it would do it from set file.

Thanks
21 REPLIES 21
Ian Miller.
Honored Contributor
Solution

Re: Change/Modify VMS file creation date

Use DFU SET FILE/CREATION_DATE command
DFU can be obtained from
http://h71000.www7.hp.com/freeware/freeware60/dfu/

or an old version from
http://h71000.www7.hp.com/freeware/freeware50/dfu027a/

why do you want to do this?
____________________
Purely Personal Opinion
Kyle Snavely_1
Advisor

Re: Change/Modify VMS file creation date

We have a bunch of file creation scripts that were supposed to run yesterday but ran today. So I want to modify the date from today to yesterday so we don't have any problems when the scripts run tonight since it concatenates files using copy/since=today
Wim Van den Wyngaert
Honored Contributor

Re: Change/Modify VMS file creation date

If you don't have the tools, you can simply do "copy x.x ;". This will re-create the file. Cleanup the previous version afterwards.
Wim
Antoniov.
Honored Contributor

Re: Change/Modify VMS file creation date

Hello Kyle,
perahps you need COPY/SINCE=/MODIF
The /MODIF operator tell to VMS check modify date instead default created date.

Bye
Antoniov
Antonio Maria Vigliotti
Wim Van den Wyngaert
Honored Contributor

Re: Change/Modify VMS file creation date

To make sure that the application behavious correctly, rename the new version to ;-1. You never now what the application is doing with the version number.
Wim
Richard W Hunt
Valued Contributor

Re: Change/Modify VMS file creation date

The only "correct" way I know of is to write (or buy) something that opens the file with an attached XAB so you can stuff a new date into the creation date slot of the appropriate field. The SET FILE /ATTRIBUTE option does not accept the CDT option.

Now, if you are REALLY REALLY GUTSY it is possible to cheat like heck by opening the index file with DCL, finding the file header, locating and updating the file date info, and recomputing the checksum for that header, then write back the block. But that is only for true masochists.

I do NOT suggest that you take it to that extreme. I have done it once in a true emergency and hope to never again need to do this. You would do better to write yourself a little utility program in BASIC, FORTRAN, or something else convenient to your site, make it use a logical name for the file name and another one for the desired date, and then just stuff the date in the XAB for the file you selected. Then you could write a little DCL script to drive it through the files you wanted to update.
Sr. Systems Janitor
Ian Miller.
Honored Contributor

Re: Change/Modify VMS file creation date

to change the date from today to yesterday you need a program that will change the file header. DFU SET FILE/CREATE will do this.
____________________
Purely Personal Opinion
Martin P.J. Zinser
Honored Contributor

Re: Change/Modify VMS file creation date

Hi,

since you already mention FILE I do recommend it once more. It is the Swiss army knife for file attributes, easy to use and I never ever had a problem with it.

File can be found at

http://vms.process.com/scripts/fileserv/fileserv_search.exe?package=file&description=&author=meadows&system=Either&language=All

Greetings, Martin
Hein van den Heuvel
Honored Contributor

Re: Change/Modify VMS file creation date

As Ian repeatedly said... DFU is your tool :-)

If somehow you can not get that going rightaway, and you have this problem to deal with, then you could consider the little program I wrote a while back. It displays the current CDT and sets to the provided argument. I'll include it below as well as attach it as text file.

hth,
Hein.

#include descrip
#include stdio
#include RMS
main(int argc, char *argv[])
{
struct FAB fab = cc$rms_fab;
struct XABDAT dat = cc$rms_xabdat;
int stat;
char ascii_date[24];
$DESCRIPTOR (date_dx, ascii_date);
if (argc < 3) return 24;
fab.fab$l_fna = argv[1];
fab.fab$b_fns = strlen(fab.fab$l_fna);
fab.fab$b_shr = FAB$M_UPI;
fab.fab$b_fac = FAB$M_PUT;
fab.fab$l_xab = &dat;
stat = SYS$OPEN ( &fab );
if (stat & 1)
{
stat = SYS$ASCTIM ( 0, &date_dx, &dat.xab$q_cdt, 0);
ascii_date[23]=0;
printf ("Creation date = %s\n", ascii_date);
date_dx.dsc$a_pointer = argv[2];
date_dx.dsc$w_length = strlen (date_dx.dsc$a_pointer);
stat = SYS$BINTIM (&date_dx, &dat.xab$q_cdt);
stat = SYS$CLOSE ( &fab );
}
return stat;
}
Ian Derringer
Regular Advisor

Re: Change/Modify VMS file creation date

You can simply change your system time & date that you want. Once you're done with and have what you need, then change the clock back.
Martin Kirby
Advisor

Re: Change/Modify VMS file creation date

re: using the XABDAT to modify the attribute.

That shouldn't work. The RMS reference manual
(V7.3-2) states that the close service only
processes XABPRO and XABRDT XABs.

I tried Hein's program on a V7.3-1 system and
it appears not to work. So I guess this is
something that changed, or was fixed, on
some version of OpenVMS.

Martin Kirby
Craig A Berry
Honored Contributor

Re: Change/Modify VMS file creation date

Note that certain invocations of the CRTL's utime will set the CDT in recent versions and on ODS-5 disks.

For some reason I can't get Hein's example to work; all the file's dates remain the same after running it, and I even stepped through it in the debugger to make sure the return values that aren't being checked were successful.

I"ve attached and included an example with the same interface as Hein's but with a completely different approach, based on the work of other people as the comments indicate.


----- zapcdt.c -----
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

struct vmsdate {
long int low;
long int high;
};

extern int main(int, char **);
int set_cdt(char *, struct vmsdate *);

int main(argc, argv)
int argc;
char *argv[];
{
static char date_string[NAM$C_MAXRSS+1];
$DESCRIPTOR(date_string_dsc, date_string);
struct vmsdate bintime;
unsigned int retsts;

/*
* If there aren't any parameters, tell the user how it's done and
* exit.
*/

if (argc < 2) {
fprintf(stderr, "Usage: %s filespec [vms_date_time]\n", argv[0]);
exit(CLI$_NULFIL);
}

/*
* If there is a second parameter, assume it is a VMS date/time string and
* parse it into a 64-bit binary date/time.
*/

if (argc > 2) {
strncpy(date_string, argv[2], sizeof(date_string));
date_string_dsc.dsc$w_length = strlen(date_string);
retsts = sys$bintim(&date_string_dsc, &bintime);
if (!(retsts & 1)) {
exit(retsts);
}

retsts = set_cdt( argv[1], &bintime );
}
else {
retsts = set_cdt( argv[1], NULL ); /* let it fill in current time */
}
exit(retsts);
}


/* set_cdt -- set the creation time and the revision time of a file
* This is based on Charles Bailey's my_utime from the Perl 5 distribution,
* except it changes the creation time as well as the revision time and has
* simpler error handling (no exception handlers).
*/

/* from the original comments in Perl's VMS.C: */
/* my_utime - update modification time of a file
* Code here is based on Joe Meadows' FILE utility.
*/

int set_cdt(char *file, struct vmsdate *date_time)
{
register int i;
static struct vmsdate bintime;
unsigned long int chan, retsts;
struct io_stat_blk { /* I/O status block */
short int completion_status;
short int msg_len;
int device_specific_info;
} iosb;
char vmsspec[NAM$C_MAXRSS+1], rsa[NAM$C_MAXRSS], esa[NAM$C_MAXRSS];
struct FAB myfab = cc$rms_fab;
struct NAM mynam = cc$rms_nam;
#if defined (__DECC) && defined (__VAX)
/* VAX DEC C atrdef.h has unsigned type for pointer member atr$l_addr,
* at least through VMS V6.1, which causes a type-conversion warning.
*/
# pragma message save
# pragma message disable cvtdiftypes
#endif
struct atrdef myatr[3] = {{sizeof bintime, ATR$C_CREDATE, &bintime},
{sizeof bintime, ATR$C_REVDATE, &bintime},
{0,0,0}};
static struct fibdef myfib;
#if defined (__DECC) && defined (__VAX)
/* This should be right after the declaration of myatr, but due
* to a bug in VAX DEC C, this takes effect a statement early.
*/
# pragma message restore
#endif
struct dsc$descriptor fibdsc = {sizeof(myfib), DSC$K_DTYPE_Z, DSC$K_CLASS_S,(char *) &myfib},
devdsc = {0,DSC$K_DTYPE_T, DSC$K_CLASS_S,0},
fnmdsc = {0,DSC$K_DTYPE_T, DSC$K_CLASS_S,0};

if (file == NULL || *file == '\0') {
return LIB$_INVARG;
}
strncpy(vmsspec, file, sizeof(vmsspec));

if (date_time != NULL) {
bintime.low = date_time->low;
bintime.high = date_time->high;
}
else {
/* Just get the current time in VMS format directly */
retsts = sys$gettim(&bintime);
if (!(retsts & 1)) {
return retsts;
}
}

myfab.fab$l_fna = vmsspec;
myfab.fab$b_fns = (unsigned char) strlen(vmsspec);
myfab.fab$l_nam = &mynam;
mynam.nam$l_esa = esa;
mynam.nam$b_ess = (unsigned char) sizeof esa;
mynam.nam$l_rsa = rsa;
mynam.nam$b_rss = (unsigned char) sizeof rsa;

/* Look for the file to be affected, letting RMS parse the file
* specification for us as well.
*/
retsts = sys$parse(&myfab,0,0);
if (!(retsts & 1)) {
return retsts;
}
retsts = sys$search(&myfab,0,0);
if (!(retsts & 1)) {
return retsts;
}

devdsc.dsc$w_length = mynam.nam$b_dev;
devdsc.dsc$a_pointer = (char *) mynam.nam$l_dev;

retsts = sys$assign(&devdsc,&chan,0,0);
if (!(retsts & 1)) {
return retsts;
}

fnmdsc.dsc$a_pointer = mynam.nam$l_name;
fnmdsc.dsc$w_length = mynam.nam$b_name + mynam.nam$b_type + mynam.nam$b_ver;

memset((void *) &myfib, 0, sizeof myfib);
#ifdef __DECC
for (i=0;i<3;i++) myfib.fib$w_fid[i] = mynam.nam$w_fid[i];
for (i=0;i<3;i++) myfib.fib$w_did[i] = mynam.nam$w_did[i];
/* This prevents the revision time of the file being reset to the current
* time as a result of our IO$_MODIFY $QIO. */
myfib.fib$l_acctl = FIB$M_NORECORD;
#else
for (i=0;i<3;i++) myfib.fib$r_fid_overlay.fib$w_fid[i] = mynam.nam$w_fid[i];
for (i=0;i<3;i++) myfib.fib$r_did_overlay.fib$w_did[i] = mynam.nam$w_did[i];
myfib.fib$r_acctl_overlay.fib$l_acctl = FIB$M_NORECORD;
#endif
retsts = sys$qiow(0,chan,IO$_MODIFY,&iosb,0,0,&fibdsc,&fnmdsc,0,0,myatr,0);
if (retsts & 1) retsts = iosb.completion_status;
if (!(retsts & 1)) {
return retsts;
}

return SS$_NORMAL;
} /* end of set_cdt() */


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

struct vmsdate {
long int low;
long int high;
};

extern int main(int, char **);
int set_cdt(char *, struct vmsdate *);

int main(argc, argv)
int argc;
char *argv[];
{
static char date_string[NAM$C_MAXRSS+1];
$DESCRIPTOR(date_string_dsc, date_string);
struct vmsdate bintime;
unsigned int retsts;

/*
* If there aren't any parameters, tell the user how it's done and
* exit.
*/

if (argc < 2) {
fprintf(stderr, "Usage: %s filespec [vms_date_time]\n", argv[0]);
exit(CLI$_NULFIL);
}

/*
* If there is a second parameter, assume it is a VMS date/time string and
* parse it into a 64-bit binary date/time.
*/

if (argc > 2) {
strncpy(date_string, argv[2], sizeof(date_string));
date_string_dsc.dsc$w_length = strlen(date_string);
retsts = sys$bintim(&date_string_dsc, &bintime);
if (!(retsts & 1)) {
exit(retsts);
}

retsts = set_cdt( argv[1], &bintime );
}
else {
retsts = set_cdt( argv[1], NULL ); /* let it fill in current time */
}
exit(retsts);
}


/* set_cdt -- set the creation time and the revision time of a file
* This is based on Charles Bailey's my_utime from the Perl 5 distribution,
* except it changes the creation time as well as the revision time and has
* simpler error handling (no exception handlers).
*/

/* from the original comments in Perl's VMS.C: */
/* my_utime - update modification time of a file
* Code here is based on Joe Meadows' FILE utility.
*/

int set_cdt(char *file, struct vmsdate *date_time)
{
register int i;
static struct vmsdate bintime;
unsigned long int chan, retsts;
struct io_stat_blk { /* I/O status block */
short int completion_status;
short int msg_len;
int device_specific_info;
} iosb;
char vmsspec[NAM$C_MAXRSS+1], rsa[NAM$C_MAXRSS], esa[NAM$C_MAXRSS];
struct FAB myfab = cc$rms_fab;
struct NAM mynam = cc$rms_nam;
#if defined (__DECC) && defined (__VAX)
/* VAX DEC C atrdef.h has unsigned type for pointer member atr$l_addr,
* at least through VMS V6.1, which causes a type-conversion warning.
*/
# pragma message save
# pragma message disable cvtdiftypes
#endif
struct atrdef myatr[3] = {{sizeof bintime, ATR$C_CREDATE, &bintime},
{sizeof bintime, ATR$C_REVDATE, &bintime},
{0,0,0}};
static struct fibdef myfib;
#if defined (__DECC) && defined (__VAX)
/* This should be right after the declaration of myatr, but due
* to a bug in VAX DEC C, this takes effect a statement early.
*/
# pragma message restore
#endif
struct dsc$descriptor fibdsc = {sizeof(myfib), DSC$K_DTYPE_Z, DSC$K_CLASS_S,(char *) &myfib},
devdsc = {0,DSC$K_DTYPE_T, DSC$K_CLASS_S,0},
fnmdsc = {0,DSC$K_DTYPE_T, DSC$K_CLASS_S,0};

if (file == NULL || *file == '\0') {
return LIB$_INVARG;
}
strncpy(vmsspec, file, sizeof(vmsspec));

if (date_time != NULL) {
bintime.low = date_time->low;
bintime.high = date_time->high;
}
else {
/* Just get the current time in VMS format directly */
retsts = sys$gettim(&bintime);
if (!(retsts & 1)) {
return retsts;
}
}

myfab.fab$l_fna = vmsspec;
myfab.fab$b_fns = (unsigned char) strlen(vmsspec);
myfab.fab$l_nam = &mynam;
mynam.nam$l_esa = esa;
mynam.nam$b_ess = (unsigned char) sizeof esa;
mynam.nam$l_rsa = rsa;
mynam.nam$b_rss = (unsigned char) sizeof rsa;

/* Look for the file to be affected, letting RMS parse the file
* specification for us as well.
*/
retsts = sys$parse(&myfab,0,0);
if (!(retsts & 1)) {
return retsts;
}
retsts = sys$search(&myfab,0,0);
if (!(retsts & 1)) {
return retsts;
}

devdsc.dsc$w_length = mynam.nam$b_dev;
devdsc.dsc$a_pointer = (char *) mynam.nam$l_dev;

retsts = sys$assign(&devdsc,&chan,0,0);
if (!(retsts & 1)) {
return retsts;
}

fnmdsc.dsc$a_pointer = mynam.nam$l_name;
fnmdsc.dsc$w_length = mynam.nam$b_name + mynam.nam$b_type + mynam.nam$b_ver;

memset((void *) &myfib, 0, sizeof myfib);
#ifdef __DECC
for (i=0;i<3;i++) myfib.fib$w_fid[i] = mynam.nam$w_fid[i];
for (i=0;i<3;i++) myfib.fib$w_did[i] = mynam.nam$w_did[i];
/* This prevents the revision time of the file being reset to the current
* time as a result of our IO$_MODIFY $QIO. */
myfib.fib$l_acctl = FIB$M_NORECORD;
#else
for (i=0;i<3;i++) myfib.fib$r_fid_overlay.fib$w_fid[i] = mynam.nam$w_fid[i];
for (i=0;i<3;i++) myfib.fib$r_did_overlay.fib$w_did[i] = mynam.nam$w_did[i];
myfib.fib$r_acctl_overlay.fib$l_acctl = FIB$M_NORECORD;
#endif
retsts = sys$qiow(0,chan,IO$_MODIFY,&iosb,0,0,&fibdsc,&fnmdsc,0,0,myatr,0);
if (retsts & 1) retsts = iosb.completion_status;
if (!(retsts & 1)) {
return retsts;
}

return SS$_NORMAL;
} /* end of set_cdt() */
----- zapcdt.c -----
Hein van den Heuvel
Honored Contributor

Re: Change/Modify VMS file creation date

I'm sorry folks. I just found that program from 1999 in my 'examples' directory and assumed it worked. I don't recall whether it was just a test of am adaption on an 'rdt' program. (and it is also ugly in its lack of proper funciton definition). $CLOSE should indeed only take inputs for XABPRO and XABRDT

Oh well...

Hein.
Hein van den Heuvel
Honored Contributor

Re: Change/Modify VMS file creation date

Digging into the past, just for grins...

I couldn't help but wonder why I had this broken example. So I hit an altavista search engine over some (hp internal) notesfiles (vms-es old and improved version of forums :-). It popped up:

10 WIZARD 3223.1 (0.14) Author: HEIN@MIASYS
Date: 18-Oct-1999 14:44:03
You can use the XAB$Q_RDT field in the XABRDT as input to a $CLOSE to change the REVISION date for a write accessed file to a user ...

$DIR/DATE [.EXAMPLES]*DT.C
$ $DIR/DATE [.EXAMPLES]*DT.C

CDT.C;4 18-OCT-1999 14:04:25.00
RDT.C;3 21-JUL-1994 00:37:18.00

Ah So! Look at the date for the file and for the reply! I must have made it to support a Wizard question:

http://h71000.www7.hp.com/wizard/wiz_3223.html

Which begs the question... is there any question left that wasn't asked and answered before :-). The tricky part is to find them!

(as bonus for reading these ramblings i'll include that rdt.c ;-).

Cheers,
Hein.

#include descrip
#include stdio
#include RMS
main(int argc, char *argv[])
{
struct FAB fab = cc$rms_fab;
struct XABRDT dat = cc$rms_xabrdt;
int stat;
int date_dx[2];

if (argc < 3) {
printf ("Usage: %s \n", argv[0]);
return 1;
}
date_dx[0] = strlen (argv[2]);
date_dx[1] = (int) argv[2];
fab.fab$l_fna = argv[1];
fab.fab$b_fns = strlen(fab.fab$l_fna);
fab.fab$b_fac = FAB$M_PUT;
fab.fab$l_xab = &dat;

stat = sys$open ( &fab );
if (stat & 1) stat = sys$bintim ( date_dx, &dat.xab$q_rdt);
if (stat & 1) stat = sys$close ( &fab );
return stat;
}
Paul Jerrom
Valued Contributor

Re: Change/Modify VMS file creation date

You can use ANAL/RMS/FDL=fdl-file to create an FDL file of the target, edit the FDL file to give it a different creation date, then CONVERT/FDL=edited-fdl-file.

I know this worked several versions of VMS ago, assume it still does...

PJ
Have fun,

Peejay
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If it can't be done with a VT220, who needs it?
Ruslan R. Laishev
Super Advisor

Re: Change/Modify VMS file creation date

Uwe Zessin
Honored Contributor

Re: Change/Modify VMS file creation date

Can you, please, put up your source code as attachments next time? That would preserve the indendation I think and make things a bit easier to understand. Thanks!
.
Ruslan R. Laishev
Super Advisor

Re: Change/Modify VMS file creation date

Sorry.
Sure.
Thanks for remind.
Uwe Zessin
Honored Contributor

Re: Change/Modify VMS file creation date

Hello, Ruslan.
The comment wasn't directed at you - as far as I can tell you posted an URL, not source code into the text entry box.
.
Hein van den Heuvel
Honored Contributor

Re: Change/Modify VMS file creation date

Uwe, I agree with you requestion in general. Both myself in my initial reply, as well as Craig, posted both the inline source and the source code as attachment. I indeed forgot to do that for my trivial additional post.
Cheers,
Hein.
Uwe Zessin
Honored Contributor

Re: Change/Modify VMS file creation date

I'm sorry, Hein. I was overwhelmed with the inline source code and missed that small attachment sign. Sigh :-(
.