Operating System - OpenVMS
1752488 Members
5817 Online
108788 Solutions
New Discussion юеВ

Re: Translating File Alias

 
SOLVED
Go to solution
Robert Atkinson
Respected Contributor

Translating File Alias

I use the SET FILE/ENTER command to create file alias' for a set of files. I need to get the original names, so the files can be printed correctly.

My intention is to use DUMP/HEAD to get the File ID, and then DUMP/HEAD/FILE to get the original file name and directory.

My question is, does anyone know of a single step DCL command, i.e. 'SHOW FILE/ALIAS'?

Rob.

16 REPLIES 16
Karl Rohwedder
Honored Contributor

Re: Translating File Alias

Maybe something like:
. a=F$Parse(F$search("b.txt"),,,"DEVICE")
. sh sym a
A = "CNC_SCRATCH:"
. b= F$file("b.txt","fid")
. ws F$fid_to_name(a,b)
DISK$CNC_DATEN:[CNC_SCRATCH.ROHW.ROHWEDDER]A.TXT;1

regards kalle
Robert Atkinson
Respected Contributor

Re: Translating File Alias

The device check isn't strictly necessary, as alias files must exist on the same volume as the original.

Unfortunately, F$FID_TO_NAME() wasn't released until 8.2, so no good for my 7.3-2 system.

Having said that, your response is very helpful, as it shows there probably isn't a direct method if HP had to realease this new lexical to fill the gap.

Rob.
Robert Gezelter
Honored Contributor

Re: Translating File Alias

Rob,

It is a bit brute force, but you can do this (iteratively) using the existing F$FILE_ATTRIBUTES lexical to match to the known File ID.

- Use F$FILE_ATTRIBUTES to get the FID of the file using the Alias entry
- Then use F$SEARCH (with wildcards) to search through candidate files until you find one with a matching File ID (using F$FILE_ATTRIBUTES at each step)

I understand that the above is tedious, but it does work on 7.3-2 (and probably on all previous versions).

- Bob Gezelter, http://www.rlgsc.com
Hein van den Heuvel
Honored Contributor

Re: Translating File Alias

Looks like a somewhat bogus question to me.
Use the alias, or don't, but don't use it and then surprise folks with the real McCoy.

But be that as it may, I did recently create a FID_TO_NAME alternative in C, simply using LIB$FID_TO_NAME. You get the required ID argument from F$FILE(x,"FID") of course.

Include below, and attached.

[btw... This topic kinda shows the importance of kindly providing the OS version and perhaps the platfom when submitting a query!]

Enjoy!
Hein van den Heuvel


/*
** fid_to_name.c Hein van den Heuvel, 2007
**
** Usage: Define as external DCL command and pass filespec as param.
** Result: DCL Symbol defined with filename as value
** $fid_to_name device index-lo sequence index-hi symbol
*/

#include
#include
#include

void set_symbol(char *symbol, char *value)
{
void lib$set_symbol();
struct {int len; char *addr;} symbol_desc, value_desc;

symbol_desc.addr = symbol;
symbol_desc.len = strlen(symbol);
value_desc.addr = value;
value_desc.len = strlen (value);
lib$set_symbol ( &symbol_desc, &value_desc);
}

main (int argc, char *argv[])
{

char device_name[128],file_name[256];
int i, s, lib$fid_to_name();
short fid[4];
struct {int len; char *addr;} device_name_desc, file_name_desc;
if (6 != argc) {
printf ("Usage: $fid_to_name device index-lo sequence index-hi symbol\n");
printf (" index-lo : fid-word-0, 16 lsb bits for file-id\n");
printf (" index-hi : fid-word-2, 8 msb bits for file-id plus rvn byte\n");
printf (" Symbol : DCL symbol to be defined with resulting filespec\n");
exit (16);
}
device_name_desc.addr = argv[1];
device_name_desc.len = strlen(argv[1]);
file_name_desc.addr = file_name;
file_name_desc.len = sizeof file_name - 1;
fid[0] = atoi ( argv[2] );
fid[1] = atoi ( argv[3] );
fid[2] = atoi ( argv[4] );
s = lib$fid_to_name ( &device_name_desc, &fid, &file_name_desc, &fid[3] );
file_name[ fid[3] ] = 0;
set_symbol ( argv[5], file_name );
}
Hein van den Heuvel
Honored Contributor

Re: Translating File Alias

Btw.. IF you have READ access to INDEXF.SYS,
THEN you can use DUMP/ID to make it get the 'original' name:

$ x="a.tmp"
$ id = f$elem(0,",",f$file(x,"FID")) - "("
$ dump/head/bloc=count=0/id='id' sys$disk/out=tmp.tmp
$ sea tmp.tmp "Dump of file"
Dump of file _DRA3:[HEIN]X.TMP;1 on 19-NOV-2007 07:17:11.68

And yet an other, cheaky, alternative is it exploit SUBMIT.
Submit goes by file ID, and SHOW ENTR will reconstruct the name:

$ subm/hold a.tmp
Job X (queue SYS$BATCH, entry 979) holding
$ show entry /full a.tmp

%JBC-E-NOSUCHENT, no such entry
$ show entry /full 979
Entry Jobname Username Blocks Status
----- ------- -------- ------ ------
979 X HEIN Holding
On idle batch queue SYS$BATCH
Submitted 19-NOV-2007 07:19:09.19 /KEEP /NOPRINT /PRIORITY=100
File: _DRA3:HEIN]X.TMP;1

Folks smarter than me could use F$GETQUI ("DISPLAY_FILE","FILE_SPECIFICATION"..)
To get the name from there.

Cheers,
Hein.





Jess Goodman
Esteemed Contributor

Re: Translating File Alias

Robert,

I'm not sure I understand why you would use two DUMP /HEADER commands. You shouldn't need to get the file ID. The command:

$ DUMP /HEAD/BLOCK=COUNT=0 aliasname

will show you the original file name in the file header's Identification area.
I have one, but it's personal.
Hein van den Heuvel
Honored Contributor

Re: Translating File Alias

Hey Jess, thanks for asking.
I did not read the question careful enough, being thown of with the DUMP/HEAD/FILE where supposedly /IDENTIFIER was intended.

Indeed, 1 dump is enough to get a FID_TO_NAME, once you have a FID from $DIRECTORY/FILE or F$FILE(file,"FID").

The queue manager hack could look like:

$ subm/hold A.TMP
Job X (queue SYS$BATCH, entry 569) holding
$ clear = F$GETQUI("CANCEL_OPERATION",,,)
$ job = F$GETQUI("DISPLAY_ENTRY","JOB_NAME",$entry,"WILDCARD")
$ file = f$getqui("DISPLAY_FILE","FILE_SPECIFICATION",,)
$ dele/entry='$entry
$ show symb file
FILE = "DRA3:[HEIN]X.TMP;1"
$

Hein.


Wim Van den Wyngaert
Honored Contributor

Re: Translating File Alias

dfu search dev/fid=x
returns the filename, not the alias.

Fwiw

Wim
Wim
Jan van den Ende
Honored Contributor

Re: Translating File Alias

@Hein:

>>>
$ file = f$getqui("DISPLAY_FILE","FILE_SPECIFICATION",,)
<<<

AFAIK, the trouble with F$getqui is that this specific attribute request does NOT work!
At least on any V7 system, up to 7,3-2.
It was reported to Engeneering, but obviously did not get enough priority.

I am a bit wondering about your last 2 commas though. They should not be relevant however.
(Can anyone test it? I am somewhere in the middle of nowhere in southern France this week, with NO VMS access).
If this CAN be made to work, we DO have some functionalities that DO need the file specs from print & batch jobs, and we would like to clean out the ugly output parsing constructs.

fwiw

Proost.

Have one on me,

jpe
fwiw
Don't rust yours pelled jacker to fine doll missed aches.