1827804 Members
2324 Online
109969 Solutions
New Discussion

Convert File to String

 
SOLVED
Go to solution
Hamiltro
Occasional Advisor

Convert File to String

Running Alpha 7.3

Long time reader first time poster

My Question, I am writing a program and wanting to pull Directory of Users, Looking at one record at a time.

$ mcr auth list USERNAME /brief
$ type sysuaf.lis /tail=1 /out=Temp.log

type temp.log displays
SMITH, JOHN SMITHJOH [11,11] 1-11111 All 4 SYS$SYSDEVICE:[SMITHJOH]

If I could turn the file into a string I could use F$Extract to get the info I need

Thanks for the help
9 REPLIES 9
Steven Schweda
Honored Contributor

Re: Convert File to String

> [...] I am writing a program [...]

In what? C? Fortran? DCL? ???

> [...] I could use F$Extract [...]

So, DCL?

> If I could turn the file into a string
> [...]

Then it would probably be too long to fit
into a DCL symbol.

Why not read (READ) it one line at a time?
Hamiltro
Occasional Advisor

Re: Convert File to String

Sorry in DCL and convert a file to a logical
Steven Schweda
Honored Contributor
Solution

Re: Convert File to String

> Why not read (READ) it one line at a time?

That is, get a listing of all the users in
one file, then read that listing:

$ mcr auth list /brief ! No USERNAME

READ will put one line into a DCL symbol, and
then you can f$locate and f$extract all you
want.


There are more direct ways to read the UAF
from DCL, but they're not so simple.
Hein van den Heuvel
Honored Contributor

Re: Convert File to String

Hamiltro,

There are several tools that are geared up help you with all of this. Google around. Mine, and at least one other is called "GETUAI", there is also an are called UAF and such.

http://vms.process.com/scripts/fileserv/fileserv.com?GETUAI

But not using a tool has its use also.
So here is a comamnd file to just grab the right fields.

Easily modified to skip the header or nor, or set outptu into a symbol.

Enjoy!
--------------------- get_defdir.com --------
$clos/nolog lis
$open/read lis sysuaf.lis
$loop:
$read/end=done lis record
$defdir = f$extr(69,99,record)
$if defdir .eqs. "Expired" then goto loop
$write sys$output f$extract(21,13,record), defdir
$goto loop
$done:
$close lis



Hoff
Honored Contributor

Re: Convert File to String

more code that does this:
http://labs.hoffmanlabs.com/node/1260
Jon Pinkley
Honored Contributor

Re: Convert File to String

Attached is an example template

Here is the output from use

$ @getuaf system
%UAF-I-LSTMSG1, writing listing file
%UAF-I-LSTMSG2, listing file SYSUAF.LIS complete
USER_LINE = "SYSTEM MANAGER SYSTEM [1,4] SYSTEM All 4 SYS$SYSROOT:[SYSMGR]"
$ @getuaf [1,7]
%UAF-I-LSTMSG1, writing listing file
%UAF-I-LSTMSG2, listing file SYSUAF.LIS complete
USER_LINE = "SYSTEST-UETP SYSTEST [1,7] SYSTEST All 4 Disuser"
USER_LINE = "SYSTEST-UETP SYSTEST_CLIG [1,7] SYSTEST All 4 Disuser"
$
it depends
Hein van den Heuvel
Honored Contributor

Re: Convert File to String


>> pull Directory of Users,

You may want to elaborate how users are selected.
Because DIR /BRIEF will only fill in the dev+dir for valid users.
My example shows there may be records marked 'Expired'.
Jon shows 'Disuser'. But I guess that is already dealt with earlier, which is why you want to deal with 1 record.

Too bad there is no F$GETUAI huh?
Personally I feel comfortable reading the columns directly from SYSUAF.DAT.
This stuff is not going to change no more.

Here is an other script I had floating around and which you might find handy.

$! uaf_defdevdir.com Hein van den Heuvel, April 2006.
$!libr/extr=$uafdef/out=uafdef.tmp sys$library:lib.mlb
$!sea uafdef.tmp _def
$!EQU UAF$S_DEFDEV 32
$!EQU UAF$T_DEFDEV 116
$!EQU UAF$S_DEFDIR 64
$!EQU UAF$T_DEFDIR 148
$!define sysuaf sys$disk:[]sysuaf.dat ! Local copy for testting
$open /write/read/share=write uaf 'f$parse("SYSUAF","SYS$SYSTEM:.DAT",,,"SYNTAX_ONLY")
$loop:
$ read/end=done uaf rec ! more than 1?
$ if p1.nes."" then read/end=done/key=&p1 uaf rec ! just 1
$ defdev=f$extr(116+1,f$cvsi(116*8,8,rec),rec)
$ defdir=f$extr(148+1,f$cvsi(148*8,8,rec),rec)
$ username=f$extr(0,12,rec)
$ write sys$output username, ": ", defdev, defdir
$ if p1.eqs."" then goto loop
$done:
$close uaf

Hamiltro
Occasional Advisor

Re: Convert File to String

Thanks for the help and the fast replys
Hamiltro
Occasional Advisor

Re: Convert File to String

Found a working solution from one of the replys