source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/ZOSVGUX.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.3 KB
Line 
1%ZOSV ;SFISC/AC,PUG/TOAD,HOU/DHW - View commands & special functions. ;4/12/07 16:48
2 ;;8.0;KERNEL;**275,425**;Jul 10, 1995;Build 18
3 ;
4ACTJ() ; # active jobs
5 I $G(^XUTL("XUSYS","CNT")) Q $G(^XUTL("XUSYS","CNT"))
6 ;This would also work
7 N %I,%FILE,Y
8 S %FILE=$$TEMP_"zosv_actj_"_$J_".tmp"
9 ZSYSTEM "ps cef -C mumps|wc>"_%FILE
10 S %I=$I
11 O %FILE
12 U %FILE R Y:99 U %I
13 C %FILE:DELETE
14 F Q:$E(Y)'=" " S $E(Y)=""
15 S Y=Y-1,^XUTL("XUSYS","CNT")=Y
16 Q Y
17 ;
18AVJ() ; # available jobs, Limit is in the OS.
19 N V,J
20 S V=^%ZOSF("VOL"),J=$O(^XTV(8989.3,1,4,"B",V,0)),J=$P($G(^XTV(8989.3,1,4,J,0),"^^1000"),"^",3)
21 Q J-$$ACTJ ;Use signon Max
22 ;
23RTNDIR() ; primary routine source directory
24 ;Assume /home/xxx/o(/home/xxx/r /home/gtm)
25 Q $P($S($ZRO["(":$P($P($ZRO,"(",2),")"),1:$ZRO)," ")_"/"
26 ;
27TEMP() ; Return path to temp directory
28 ;N %TEMP S %TEMP=$P($$RTNDIR," "),%TEMP=$P(%TEMP,"/",1,$L(%TEMP,"/")-2)_"/t/"
29 Q $G(^%ZOSF("TMP"),$G(^XTV(8989.3,1,"DEV"),"/tmp/"))
30 ;
31PASSALL ;
32 U $I:(NOESCAPE:NOTERMINATOR:PASTHRU) Q
33NOPASS ;
34 U $I:(ESCAPE:TERMINATOR="":NOPASTHRU) Q
35 ;
36GETPEER() ;Get the IP address of a connection peer
37 N % S %=$P($ZTRNLNM("SSH_CLIENT")," ") S:%="" %=$ZTRNLNM("REMOTEHOST")
38 Q $S($L(%):%,$L($G(IO("GTM-IP"))):IO("GTM-IP"),1:"")
39 ;
40PRGMODE ;Drop into direct mode
41 N X,XUCI,XUSLNT
42 W ! S ZTPAC=$P($G(^VA(200,+DUZ,.1)),"^",5),XUVOL=^%ZOSF("VOL")
43 S X="" X ^%ZOSF("EOFF") R:ZTPAC]"" !,"PAC: ",X:60 D LC^XUS X ^%ZOSF("EON") I X'=ZTPAC W "??",$C(7) Q
44 N XMB,XMTEXT,XMY S XMB="XUPROGMODE",XMB(1)=DUZ,XMB(2)=$I D ^XMB:$L($T(^XMB)) D BYE^XUSCLEAN K ZTPAC,X,XMB
45 D UCI S XUCI=Y D PRGM^ZUA
46 F BREAK
47 HALT
48 ;
49PROGMODE() ; In Application mode
50 Q 0 ; This was used to control UCI switching, has no meaning in GT.M
51 ;
52UCI ;
53 S Y=^%ZOSF("PROD") Q
54 ;
55UCICHECK(X) ;
56 Q X
57 ;
58JOBPAR ; <=====
59 N %FILE,%I S %FILE=$$PWD^%ZISH_"zosv_jobpar_"_$J_".tmp"
60 ZSYSTEM "ps c -p "_X_"|tail -1>"_%FILE
61 S %I=$I
62 O %FILE
63 U %FILE R Y:99 U %I
64 C %FILE:DELETE
65 F Q:$E(Y)'=" " S $E(Y)=""
66 I +Y=X,$E(Y,$L(Y)-4,$L(Y))="mumps" S Y=^%ZOSF("PROD")
67 E S Y=""
68 Q
69 ;
70SHARELIC(TYPE) ;Used by Cache implementations
71 Q
72 ;
73PRIORITY ;
74 K Y ; VA has this disabled in general.
75 Q
76 ;
77PRIINQ() ;
78 Q 5 ; for now, we're always middle of the road
79 ;
80BAUD S X="UNKNOWN"
81 Q
82 ;
83LGR() ; Last global reference ($REFERENCE)
84 Q $R
85 ;
86EC() ; Error Code: returning $ZS in format more like $ZE from DSM
87 N %ZE
88 I $ZS="" S %ZE=""
89 S %ZE=$P($ZS,",",2)_","_$P($ZS,",",4)_","_$P($ZS,",")_",-"_$P($ZS,",",3)
90 Q %ZE
91 ;
92DOLRO ;SAVE ENTIRE SYMBOL TABLE IN LOCATION SPECIFIED BY X
93 ;S Y="%" F S Y=$O(@Y) Q:Y="" D
94 ;. I $D(@Y)#2 S @(X_"Y)="_Y)
95 ;. I $D(@Y)>9 S %X=Y_"(",%Y=X_"Y," D %XY^%RCR
96 S Y="%" F M:$D(@Y) @(X_"Y)="_Y) S Y=$O(@Y) Q:Y=""
97 Q
98 ;
99ORDER ;SAVE PART OF SYMBOL TABLE IN LOCATION SPECIFIED BY X
100 N %
101 S (Y,%)=$P(Y,"*",1) ;I $D(@Y)=0 F S Y=$O(@Y) Q:Y=""!(Y[Y1)
102 Q:Y=""
103 ;S %=$D(@Y) S:%#2 @(X_"Y)="_Y) I %>9 S %X=Y_"(",%Y=X_"Y," D %XY^%RCR
104 ;F S Y=$O(@Y) Q:Y=""!(Y'[Y1) S %=$D(@Y) S:%#2 @(X_"Y)="_Y) I %>9 S %X=Y_"(",%Y=X_"Y," D %XY^%RCR
105 F M:$D(@Y) @(X_"Y)="_Y) S Y=$O(@Y) Q:Y=""!(Y'[%)
106 Q
107 ;
108PARSIZ ;
109 S X=3 Q
110 ;
111NOLOG ;
112 S Y=0 Q
113 ;
114GETENV ;Get environment Return Y='UCI^VOL^NODE^BOX LOOKUP'
115 N %HOST,%V S %V=^%ZOSF("PROD"),%HOST=$$RETURN("hostname -s")
116 S Y=$TR(%V,",","^")_"^"_%HOST_"^"_$P(%V,",",2)_":"_%HOST
117 Q
118 ;
119VERSION(X) ;return OS version, X=1 - return OS
120 Q $S($G(X):$P($ZV," V"),1:+$P($ZV," V",2))
121 ;
122OS() ;
123 Q "UNIX"
124 ;
125SETNM(X) ;Set name, Trap dup's, Fall into SETENV
126 N $ETRAP S $ETRAP="S $ECODE="""" Q"
127SETENV ;Set environment X='PROCESS NAME^ '
128 S ^XUTL("XUSYS",$J,0)=$H,^("NM")=X ; workaround
129 Q
130 ;
131SID() ;System ID
132 N J1,T S T="~"
133 S J1(1)=$ZROUTINES,J1(1)=$P(J1(1)," ")
134 S J1(2)=$ZGBLDIR
135 Q "1~"_J1(1)_T_J1(2)
136 ;
137PRI() ;Check if a mixed OS enviroment.
138 ;Default return 1 unless we are on the secondary OS.
139 ;Only Cache on a VMS/Linux mix is supported now.
140 Q 1
141 ;
142T0 ; start RT clock
143 Q ; we don't have $ZH on GT.M
144 ;
145T1 ; store RT datum w/ZHDIF
146 Q ; we don't have $ZH on GT.M
147 ;
148ZHDIF ;Display dif of two $ZH's
149 W !," ET=",$J(($P(%ZH1,",")-$P(%ZH0,",")*86400)+($P(%ZH1,",",2)-$P(%ZH0,",",2)),6,2)
150 Q
151 ;
152 ;Code moved to %ZOSVKR, Comment out if needed.
153LOGRSRC(OPT,TYPE,STATUS) ;record resource usage in ^XTMP("KMPR"
154 Q:'$G(^%ZTSCH("LOGRSRC")) ; quit if RUM not turned on.
155 ; call to RUM routine.
156 D RU^%ZOSVKR($G(OPT),$G(TYPE),$G(STATUS))
157 Q
158 ;
159SETTRM(X) ;Turn on specified terminators.
160 U $I:(TERMINATOR=X)
161 Q 1
162 ;
163DEVOK ;
164 ;use lsof (list open files)
165 ; given a device name in X
166 ;INPUT: X=Device $I, X1=IOT -- X1 needed for resources
167 ;OUTPUT: Y=0 if available, Y=job # if owned
168 ; Y=-1 if device does not exists.
169 ; return Y=0 if not owned, Y=$J of owning job, Y=999 if dev cycling
170 ;
171 I $G(X1)="RES" G RESOK^%ZIS6
172 S Y=0
173 Q ;Let ZIS deal with it.
174 ;
175 N %FILE S %FILE=$$TEMP_"zosv_devok_"_$J_".tmp"
176 ZSYSTEM "/usr/sbin/lsof -F Pc "_X_" >"_%FILE
177 N %I,%X,%Y S %I=$I
178 O %FILE U %FILE
179 F %Y=0:1 R %X:99 Q:%X="" Q:%X["lsof: status error" D
180 . S %Y(%Y\2,$S($E(%X)="p":"PID",$E(%X)="c":"CMD",1:"?"))=$E(%X,2,$L(%X))
181 U %I
182 C %FILE:(DELETE)
183 I %X["lsof: status error" S Y=-1 Q
184 S %X="",Y=0
185 F S %X=$O(%Y(%X)) Q:%X="" I %Y(%X,"CMD")="mumps" S Y=%Y(%X,"PID") Q
186 Q
187 ;
188DEVOPN ;List of Devices opened. Linux only
189 ;Returns variable Y. Y=Devices owned separated by a comma
190 ; ZSHOW "D":Y
191 N %FILE S %FILE=$$TEMP_"zosv_devopn_"_$J_".tmp"
192 ZSYSTEM "lsof -F n -p "_$J_" >"_%FILE
193 N %I,%X,%Y S %I=$I
194 O %FILE
195 U %FILE
196 F %Y=0:1 R %X:99 Q:%X="" S %Y($S($E(%X)="p":"PID",$E(%X)="n":%Y,1:"?"))=$E(%X,2,$L(%X))
197 U %I
198 C %FILE:(DELETE)
199 I %Y("PID")'=$J S Y="" Q
200 I $D(%Y("?")) S Y="" Q
201 K %Y("PID"),%Y("?")
202 S (Y,%X)="" F S %X=$O(%Y(%X)) Q:%X="" S Y=Y_","_%Y(%X)
203 Q
204 ;
205RETURN(%COMMAND) ; ** Private Entry Point: execute a shell command & return the resulting value **
206 ; %COMMAND is the string value of the Linux command
207 N %VALUE S %VALUE="" ; value to return
208 N %FILE S %FILE=$$TEMP_"RET"_$J_".txt" ; temporary results file
209 ZSYSTEM %COMMAND_" > "_%FILE ; execute command & save result
210 O %FILE:(REWIND) U %FILE R:'$ZEOF %VALUE:99 C %FILE:(DELETE) ; fetch value & delete file
211 ;
212 QUIT %VALUE ; return value
213 ;
214 ;
215STRIPCR(%DIRECT) ; ** Private Entry Point: strip extraneous CR from end of lines of all
216 ; routines in %DIRECTORY Linux directory
217 ;
218 ZSYSTEM "perl -pi -e 's/\r\n$/\n/' "_%DIRECT_"[A-K]*.m"
219 ZSYSTEM "perl -pi -e 's/\r\n$/\n/' "_%DIRECT_"[L-S]*.m"
220 ZSYSTEM "perl -pi -e 's/\r\n$/\n/' "_%DIRECT_"[T-z]*.m"
221 ZSYSTEM "perl -pi -e 's/\r\n$/\n/' "_%DIRECT_"[_]*.m"
222 Q
223 ;
Note: See TracBrowser for help on using the repository browser.