HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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.
Hein van den Heuvel
Honored Contributor

Re: Translating File Alias

Jan,

[Veel plezier in Frankrijk. Ik ben jaloers!]

The commands above were issued on an 7.2-1 system (EISNER).

The commas are optional. Just cut & paste left-over.

As you well know, the GETQUI stuff is tricky though.
It's all too easy to get: %JBC-E-NOJOBCTX, no job context

And it is easy to get nothing back on the
"DISPLAY_FILE","FILE_SPECIFICATION"
if one asks a second DISPLAY _FILE item without "FREEZE_CONTEXT".

hth,
Hein.
Jess Goodman
Esteemed Contributor

Re: Translating File Alias

Jan,

Hein's F$GETQUI code works on VMS 7.3-2 and below. I consider myself well-versed in the intricacies of F$GETQUI from my work on DISPLAY_JOBS.COM and, although it can be somewhat non-intuitive, it works as advertised/documented. I'm curious what problem was reported to VMS engineering.

Hein,

Robert's original post said "so the files can be printed correctly", so it might make more sense for him to use a PRINT command instead of a SUBMIT with your suggestion.

Then he might just have to do:
$ SET ENTRY '$ENTRY' /RELEASE/other_stuff
instead of the DELETE/ENTRY='$ENTRY
I have one, but it's personal.
Jess Goodman
Esteemed Contributor

Re: Translating File Alias

I was a bit too kind above...

I just remembered there IS a problem with F$GETQUI item codes "FILE_SPECIFICATION" and "LOG_SPECIFICATION" that I found in my DISPLAY_JOBS.COM testing under VMS 7.3-2. However it only affects very-long file specifications.

When these file-specifications get close to the 255 byte limit, F$GETQUI will return them with a Directory ID abbreviation. But if this does not shorten the filespec (and it could make it longer) the filespec is then just truncated. It is never returned with a File ID abbreviation.

I haven't tested it but I would guess the problem is in the SYS$GETQUI service itself.
I don't believe $GETQUI was ever documented as being fully compatible with extended filespecs, but still it would be nice if this could be fixed (if it hasn't been already).

If someone with software-support can confirm this under VMS 8.3 and report it I would appreciate it.
I have one, but it's personal.
Hoff
Honored Contributor
Solution

Re: Translating File Alias

Brute force, unsupported, subject to change without notice, don't call HP support upon incidents of breakage, blah-blah-blah...

Your proposed approach is likely the fastest approach...

Grab the FID (which you probably have), toss it at DUMP/FID, and snag the output off a PIPE. (Getting the PIPE output into a logical name is discussed in the OpenVMS FAQ in relation to ampersand substitution, among other places, and you can certainly get it written into a file with little effort.)

To wit:

$ copy nla0: xyzzy.txt
$ set file/enter=plugh.txt xyzzy.txt
(insert f$file FID call here)
$ directory/file plugh.txt

Directory DISK$DV:[BOGO]

PLUGH.TXT;1 (10211,29,0)

Total of 1 file.
$ set process/privilege=readall
$ dump/id=(10211,29,0) disk$dv:/header
$ pipe dump/id=(10211,29,0) disk$dv:/header | search sys$pipe "Dump of file"
Dump of file DVA0:[BOGO]XYZZY.TXT;1 on 21-NOV-2007 00:53:34.48
$

And to answer your question, "no".

Recognize that file links have seen various changes in OpenVMS in recent releases; see the hardlinks and mount points details in the OpenVMS release notes. (I don't know if any of these will derail your efforts here.)

Stephen Hoffman
HoffmanLabs LLC

Robert Atkinson
Respected Contributor

Re: Translating File Alias

To answer a few questions raised.....

Jess - I need to use DUMP/ID to retrieve the directory. The Header ID area doesn't contain this.

Hein - the reason we are using file alias is so that we can group a bunch of reports togeather, one group per recipient (e.g. GROUP1_REPORT1.TXT, GROUP1_REPORT2.TXT). I guess we could copy them to a directory, or a specific name, but file alias was the best approach when we wrote this 15 years ago. It just so happens that it's now important the files get passed to another new system with their original names.

Hoff - thanks for your reply. In the end, I used the approach you outlined, all-be-it a little more bloated :-

$ DEVICE = F$PARSE(CURRFILE,,,"DEVICE") - ":"
$ !
$ DUMP /HEAD /BLOCK=COUNT=0 /OUT=SYS$TEMP:DAYROY_HEADER_1.TMP 'CURRFILE'
$ @'$SYLIB'EXTRACT_REPORT_LINE SYS$TEMP:DAYROY_HEADER_1.TMP " File identification:" 0
$ !
$ IF EXTRACTED_LINE .EQS. "STRINGNOTFOUND"
$ THEN
$ ERRORMOD DAYROYALTY MAIL "Could not translate alias for file ''CURRFILE' - ignoring"
$ GOTO EXPAND_TO_PORTAL_LOOP
$ ENDIF
$ !
$ FID_LINE = F$EDIT(EXTRACTED_LINE,"COLLAPSE")
$ FID = F$ELEM(1,":",FID_LINE)
$ !
$ DUMP /HEAD /BLOCK=COUNT=0 /ID='FID' /OUT=SYS$TEMP:DAYROY_HEADER_2.TMP 'DEVICE':*.*
$ @'$SYLIB'EXTRACT_REPORT_LINE SYS$TEMP:DAYROY_HEADER_2.TMP "Dump of file" 0
$ !
$ IF EXTRACTED_LINE .EQS. "STRINGNOTFOUND"
$ THEN
$ ERRORMOD DAYROYALTY MAIL "Could not translate alias for file ''CURRFILE' - ignoring"
$ GOTO EXPAND_TO_PORTAL_LOOP
$ ENDIF
$ !
$ ORIGFILE = F$ELEM(3," ",EXTRACTED_LINE)
$ !
$ WS "File translated back to ''ORIGFILE'"
$ !

Rob.
Robert Atkinson
Respected Contributor

Re: Translating File Alias

See post above for final solution.

Thanks to all that gave input.

Rob.
Hein van den Heuvel
Honored Contributor

Re: Translating File Alias

Robert,

The assigned points,, and your final solution suggest that you did not really bother to read the replies. That's dissapointing.

The initial dump to get the file ID is a silly waste of resources at was pointed out already.

You can get the file ID for free from F$FILE(file,"FID")
and for next to nothing from DIRECTOR/FILE.

I used that in the first solution:
"$ 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"

Why go to the trouble of dumping to a file reading back.


Also, I found it well worth my while to use the trivial C program posted above to provide a temporary F$FID_TO_NAME function unitll your ssytem run a VMS version with that build in.

Yeah I know, some systems envronments are difficult about add an 'unsupported' C 'program' to a toolset where they readily add a ton of equally unsupport utility command files like the 'EXTRACT_REPORT_LINE' here which do only half the job using twice the recources. Oh well!

Cheers,
Hein.