VMS File Operations (for beginners)

I first encountered VMS sometime in the 1980’s after having used an ICL1900 and a DEC System 20 and I’ve been a bit of a fan ever since, particularly of the file system which supports file versioning, which is something I still miss on more modern systems today.

Experienced VMS users will be very familiar with this but for anyone who is coming to VMS as a hobbyist for the first time I’ve put together some examples of some of the slightly less than obvious things you can do when copying, renaming and deleting files.

Starting with a folder containing two versions of a program we can use the ‘DIR’ command to display all the files in the folder.

$ dir time.* /prot/columns=1
Directory
TIME.C;2 (RD,RWED,,)
TIME.C;1 (RD,RE,,)
TIME.EXE;2 (RD,RWED,,)
TIME.EXE;1 (RD,RE,,)
Total of 4 files
$

One of the first things you will notice is that the different versions of the files have different permissions, normally new versions of existing files normally inherit the same permissions as the original. However in this case, I’ve deliberately modified the permissions of the original version to prevent it being accidentally deleted.

If you edit the source code then the system will save the modified version of the code in a new file, you don’t need to keep a backup copy, every time you edit (or copy) a file a new version will be created.

$ edit time.c
$ dir time.* /columns=1
Directory
TIME.C;3
TIME.C;2
TIME.C;1
TIME.EXE;2
TIME.EXE;1
Total of 5 files
$

You can get rid of old versions of files you don’t want using the ‘PURGE’ command, by default this only keeps the latest version of each file but you can specify how many to keep. Having changed the file permissions the original versions of the files prevents them from being deleted – unless you are using a privileged account which can bypass file permissions, in which case be very careful what you do!

$ pu
%PURGE-I-FILPURG, TIME.C;2 deleted (6 blocks)
%PURGE-W-FILNOTPUR, error deleting TIME.C;1
-SYSTEM-F-NOPRIV, no privilege for attempted operation
%PURGE-I-TOTAL, 1 file deleted (6 blocks)
$ dir time.* /columns=1
Directory
TIME.C;3
TIME.C;1
TIME.EXE;2
TIME.EXE;1
Total of 4 files
$

If you don’t specify a version number then the file specification will match only the most recent version of the file, unless the command acts on multiple files multiple files in which case it will match every version of the file, however if the version number is empty or blank then the file specification will only ever match the most recent version.

$ dir time.c /columns=1
Directory
TIME.C;3
TIME.C;1
Total of 2 files
$ copy time.c time.c /log
%COPY-S-COPIED, TIME.C;3 copied to TIME.C;4 (6 blocks)
$ dir time.c; /columns=1
Directory
TIME.C;4
Total of 1 files

You can also specify previous versions of a file by using a negative version number, however when renaming a file all negative values are treated as if they were minus one.

$ dir time.c;-2 /columns=1
Directory
TIME.C;1
Total of 1 files

$ pu
%PURGE-I-FILPURG, TIME.C;3 deleted (6 blocks)
%PURGE-W-FILNOTPUR, error deleting TIME.C;1
-SYSTEM-F-NOPRIV, no privilege for attempted operation
%PURGE-I-TOTAL, 1 file deleted (6 blocks)

$ ren time.c; *.*;-1 /log
%RENAME-I-RENAMED, TIME.C;4 renamed to TIME.C;2

When I want to keep the current version of a file, I create a new working copy, and then modify the file permissions on the last working version to prevent it being accidentally deleted or purged.

$ copy time.*; *.*;
%COPY-S-COPIED, TIME.C;2 copied to TIME.C;3 (4 blocks)
%COPY-S-COPIED, TIME.EXE;2 copied to TIME.EXE;3 (119 blocks)
%COPY-S-NEWFILES, 2 files created
$ dir time.* /prot/columns=1
Directory
TIME.C;3 (RD,RWED,,)
TIME.C;2 (RD,RWED,,)
TIME.C;1 (RD,RE,,)
TIME.EXE;3 (RD,RWED,,)
TIME.EXE;2 (RD,RWED,,)
TIME.EXE;1 (RD,RE,,)
Total of 6 files
$ set file /prot=o:re env.*;-1
$ dir time.* /prot/columns=1
Directory
TIME.C;3 (RD,RWED,,)
TIME.C;2 (RD,RE,,)
TIME.C;1 (RD,RE,,)
TIME.EXE;3 (RD,RWED,,)
TIME.EXE;2 (RD,RE,,)
TIME.EXE;1 (RD,RE,,)
Total of 6 files

That’s all for now – but if you have any (useful) tips or tricks for working with different file versions on VMS let me know and I might add them to this page (if they are not too obscure!).

This entry was posted in VMS and tagged , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s