RMS access using high level API
Source code:
1 # import pprint
2 import struct
3 import vms.rms
4 from vms.fabdef import *
5 import vms.starlet
6
7 acc = FAB_M_GET
8 shr = FAB_M_SHRPUT + FAB_M_SHRGET + FAB_M_SHRDEL + FAB_M_SHRUPD
9 f = vms.rms.file('sysuaf',fac=acc, shr=shr)
10
11 print f.longname
12 print 'Number of keys:', f.nok
13 print
14
15 print 'Alphabetic order'
16 print '%-32s %-20s %s' %('Username', 'UIC', 'Last Interactive Login')
17 print '-'*78
18
19 for i in range(4):
20 s,r = f.fetch()
21 lst = struct.unpack("=i32sHHIQ32s32p32p64p64p32p32pQQHHBBBBQQQQQQQQ",
22 r[:428])
23 # pprint.pprint(lst)
24 uic = '[%o,%o]' % (lst[3], lst[2])
25 print '%s %-16s %28s' % (lst[1], uic, vms.starlet.asctim(lst[25])[1])
26
27 print
28 print 'UIC order'
29 print '%-32s %-20s %s' %('Username', 'UIC', 'Last Interactive Login')
30 print '-'*78
31
32 f.usekey(1)
33 f.rewind()
34 i = 0
35 for r in f:
36 i += 1
37 if (i > 4): break
38 lst = struct.unpack("=i32sHHIQ32s32p32p64p64p32p32pQQHHBBBBQQQQQQQQ",
39 r[:428])
40 # pprint.pprint(lst)
41 uic = '[%o,%o]' % (lst[3], lst[2])
42 print '%s %-16s %28s' % (lst[1], uic, vms.starlet.asctim(lst[25])[1])
43
44 f.close()
Result:
SYS$COMMON:[SYSEXE]SYSUAF.DAT;1 Number of keys: 4 Alphabetic order Username UIC Last Interactive Login ------------------------------------------------------------------------------ AUSER [700,4] 13-SEP-2001 16:10:24.11 BUSER [3376,1] 17-NOV-1858 00:00:00.00 CUSER [700,7] 17-NOV-1858 00:00:00.00 DUSER [700,10] 27-SEP-2002 12:49:57.24 UIC order Username UIC Last Interactive Login ------------------------------------------------------------------------------ SYSTEM [1,4] 22-NOV-2002 18:17:10.09 SYSTEST [1,7] 17-NOV-1858 00:00:00.00 SYSTEST_CLIG [1,7] 17-NOV-1858 00:00:00.00 FIELD [1,10] 27-SEP-2002 21:11:11.21
