Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a userlist of menu access work file

 
SOLVED
Go to solution
Tedj400
Occasional Visitor

Creating a userlist of menu access work file

I am very new to the DCL programming world and I need some help on a program to capture all the user access to a software application for a CSOX requirement.

I have created a simple program for one user work directory and one menu file which works but I need to make the program generic and dynamic so that it will loop through all the users work directories and read all the menu files and append the menu file and user to each record.

This is what I have:

$ SET DEF [TJOHNSON]
$ OPEN/READ INFILE MENU.DAT
$ OPEN/WRITE OUTFILE USERLIST.LIS
$ READ_FILE:
$ READ/END_OF_FILE=DONE INFILE DATA
$ WRITE OUTFILE DATA,";", "MENU.DAT",";", "TJOHNSON"
$ GOTO READ_FILE
$ DONE:
$ CLOSE INFILE
$ CLOSE OUTFILE
$ TYPE USERLIST.LIS
$ EXIT

I need the SET DEF line to change to the users working directory"[TJOHNSON]" and not hard coded like my example.

1. All the users work directories are located under the SYS$SYSDEVICE FOLDER.

2. Each work directory contains about 40 *MENU.DAT files. All the menus end with MENU.DAT.

3. I need to read each record in the table and append it with the menu file name and the user(Work directory).

4. Once I have this information in a work file I can FTP the data down to access and create a report with crystal.

I can probably do this with a lot of hard coding and repetition.

Any Ideas?

7 REPLIES 7
Hoff
Honored Contributor

Re: Creating a userlist of menu access work file

The following is probably going to make little or no sense to you without better grounding in OpenVMS terms and concepts and in DCL (and no offense is intended here) that you clearly lack.

Before you read further in this reply, please go read through the OpenVMS User's Guide, skim the DCL dictionary and particularly the lexical functions, and skim the programming concepts manual.

http://www.hp.com/go/openvms/doc

>I need the SET DEF line to change to the users working directory"[TJOHNSON]" and not hard coded like my example.

See SYS$LOGIN and SYS$LOGIN_DEVICE, or set up your own site-local logical names.

Logical names and symbol substitution are key concepts for DCL programming, as are DCL lexical functions.

>1. All the users work directories are located under the SYS$SYSDEVICE FOLDER.

SYS$SYSDEVICE Folder? No.

SYS$SYSDEVICE is a logical name that refers to the system disk device.

If I'm building a menu system, I'd tend to have my own logical name for the device and (not folder) directory involved with the menu.

>2. Each work directory contains about 40 *MENU.DAT files. All the menus end with MENU.DAT.

That's going to be a maintenance problem, but you probably know that. And you need to guard against the user writing to the directory and clobbering those files, too.

>3. I need to read each record in the table and append it with the menu file name and the user(Work directory).

Ok. Go read it. (If that's your design.)

>4. Once I have this information in a work file I can FTP the data down to access and create a report with crystal.

COPY /FTP is your best friend here.

Work file?

>I can probably do this with a lot of hard coding and repetition.

Invest in learning before investing in brute-force.

>Any Ideas?

Read the manuals? (Seriously.)

If you're interested in seeing a combination of a DCL menu system and OpenVMS DCL code and OpenVMS C code and other such, see:

http://labs.hoffmanlabs.com/node/1260
RBrown_1
Trusted Contributor

Re: Creating a userlist of menu access work file

1. I don't see why you need to SET DEFAULT at all. You just need to find and read the files, right? SET DEFAULT is not required for that.

2. Do you really want to create USERLIST.LIS in each directory where you find *MENU.DAT?

In any case, the DCL lexicals you will find useful are F$SEARCH and perhaps F$PARSE.

Will it be sufficient to simply find all *MENU.DAT on SYS$SYSDEVICE? F$SEARCH will do that. If you have a subset of directories to search rather than the whole disk then perhaps you will want another loop.

Have fun.
Tedj400
Occasional Visitor

Re: Creating a userlist of menu access work file

the problem is that there is menu.dat file in each user directory so if there are 40 users and your right I only want one work file.

I have made some progress and figured out how to loop through the work directories.
Just need to figure out how to loop through all the *Menu.dat tables in the directory. Currently this program is hard coded for one table "Menu.dat"

$! Created by......: ****** August 2009.
$! Description.....: Create a user list with Menu access
$!********************************************************
$! Open the work table
$! Get all the users from the SYSUAF file
$! Do while you have a User
$! Set the directory to the User
$! Check for a Menu file
$! Do while there is a record
$! Write to the work file with the file and the user
$! End
$! End
$!*****************************************************
$ OPEN/WRITE OUTFILE [TJOHNSON]USERLIST.LIS
$open /write/read/share=write uaf 'f$parse("SYSUAF","SYS$SYSTEM:.DAT",,,"SYNTAX)
$loop:
$ read/end=done uaf rec ! more than 1?
$ if p1.nes."" then read/end=done/key=&p1 uaf rec ! just 1
$ defdir=f$extr(148+1,f$cvsi(148*8,8,rec),rec)
$ SET DEF &defdir
$ OPEN/READ INFILE/ERROR=OPEN_ERROR MENU.DAT
$ READ_FILE:
$ READ/END_OF_FILE=DONE INFILE DATA
$ WRITE OUTFILE DATA,";", "MENU.DAT",";", defdir
$ GOTO READ_FILE
$ DONE:
$ CLOSE INFILE
$ OPEN_ERROR:
$ if p1.eqs."" then goto loop
$done:
$ CLOSE OUTFILE
$close uaf
Hoff
Honored Contributor

Re: Creating a userlist of menu access work file


$ sourcedir = "SYS$LOGIN:*.TMP"
$ next = f$search("RESET_SEARCH_CONTEXT.BOGUS_TMP;0",1)
...
$loop:
$ nextfile = f$search(sourcedir,1)
$ if f$length(nextfile) .eq. 0 then goto done
....
$ goto loop
$done:
...
$ exit
RBrown_1
Trusted Contributor
Solution

Re: Creating a userlist of menu access work file

> the problem is that there is menu.dat
> file in each user directory

I don't see that problem. Did you check HELP LEXICALS F$SEARCH? Will F$SEARCH ("SYS$SYSDEVICE:[*...]*MENU.DAT") find files that you don't want? Will you be able to tell that you don't want them?

> I have made some progress and figured out
> how to loop through the work directories.

OK. I see you pulling out the login directory but not the login device. This will fail if you get a user with a different login device from the current default device when your command file is run.

> Just need to figure out how to loop
> through all the *Menu.dat tables in the
> directory.

See my previous clues about F$SEARCH.

I still think that your SET DEFAULT commands are unnecessary. You can specify the device and directory information in your OPEN statement or in your F$SEARCH command.

Willem Grooters
Honored Contributor

Re: Creating a userlist of menu access work file

After a quick scan of the problem and the bits of solutions, the right solution is "read the manuals". Pay particular attention to:

* Logicals
* File system
* DCL in general, and file access and lexical functions in particular

Some system management may be handy: you can specify what would be the defaults for any user ("working diectory" in UNIX terms), the type of account, facilities available and, in your case, what procedure to be executed, all set wehn this user logs in.

You won't need a SET DEFAULT at any time.

Keep in mind that a carefully designed system would be centrally maintainable with minimal effort and still be crystal clear for auditors. You cannot built such a system by thinking fingers.
Willem Grooters
OpenVMS Developer & System Manager
Tedj400
Occasional Visitor

Re: Creating a userlist of menu access work file

Thanks for the Help