Changeset 640 for trunk/guitools/shared/smbtree.vrs
- Timestamp:
- Sep 25, 2011, 7:05:11 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/guitools/shared/smbtree.vrs
r638 r640 10 10 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N' 11 11 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0 12 13 12 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = '' 14 13 15 say ' detach 'samba.!smbtreeexe' 'BroadCast' -S 'debuglevel' 'UserCred' >'samba.!msg 16 address cmd 'detach 'samba.!smbtreeexe' 'BroadCast' -S 'debuglevel' 'UserCred' >'samba.!msg 14 say " UserCred="UserCred 15 16 /* smbtree -S = List workgroups (domains) and servers of tree */ 17 say ' detach 'samba.!smbtreeexe' 'BroadCast' -S 'UserCred' 'debuglevel' >'samba.!msg 18 address cmd 'detach 'samba.!smbtreeexe' 'BroadCast' -S 'UserCred' 'debuglevel' >'samba.!msg 17 19 18 20 if BroadCast = '-b' then BroadCast = 1; else BroadCast = 0 … … 31 33 _RefreshTreeDisplay: 32 34 say time()' _RefreshTreeDisplay() started' 33 say ' samba.!msg = "'samba.!msg'"' 35 34 36 stat = stream(samba.!msg,'c','open read') 35 37 if stat <> "READY:" then return 36 38 37 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then do 38 UserCred = '-N' 39 end 40 39 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N' 41 40 if ShowHidden = 'SHOWHIDDEN' | ShowHidden = '' then ShowHidden = 0 41 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = '' 42 42 43 43 ok = VRset("TM_RefreshTreeDisplay","Enabled",0) 44 /* ok = VRSet("Main", "StatusText", NLVGetMessage(50)) */45 44 ok = VRSet("CN_smbtree", 'Enabled', 0 ) 46 /* ok = VRSet("Main", 'Pointer', 'Wait' ) */47 45 48 46 ok = VRSet( "CN_smbtree", "Painting", 0 ) … … 50 48 51 49 drop smbtree. 52 drop smbtreeline. 53 54 sl = 0 55 56 do until lines(samba.!msg) = 0 57 sl = sl + 1 58 smbtreeline.sl = linein(samba.!msg) 59 end 60 smbtreeline.0 = sl 61 ok = stream(samba.!msg,'c','close') 62 ok = SysFileDelete(samba.!msg) 50 51 ok = file2stem(samba.!msg,"smbtreeline.") 63 52 64 53 do sl = 1 to smbtreeline.0 65 54 Header = c2x(left(smbtreeline.sl,3)) 66 55 select 67 when Header = "09095C" then do /* share - obsolete, we do that differently now see below! */ 68 smbtreeline.sl = strip(smbtreeline.sl,,'09'x) 69 parse var smbtreeline.sl '\\'machine'\'share '09'x comment 70 machine = strip(machine) 71 share = strip(share) 72 comment = strip(comment) 73 text = translate(share' 'comment) 74 res = _GuessIcon(text) 75 if VRGet("CN_smbtree","View") = "IconTree" then do 76 parent = smbtree.!machine 77 smbtree.!share = VRMethod( "CN_smbtree", "AddRecord",parent,, share||'0D0A'x||comment, res) 78 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "ReadOnly", 1) 79 if pos("$", share) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!share, "Visible", ShowHidden) 80 end 81 end /* end of obsolete share code */ 82 when Header = "095C5C" then do /* Machine */ 56 when Header = "09095C" then nop /* share - obsolete, we only list domains and servers here */ 57 when Header = "095C5C" then do /* machine */ 83 58 smbtreeline.sl = strip(smbtreeline.sl,,'09'x) 84 59 parse var smbtreeline.sl '\\'machine '0909'x comment … … 86 61 comment = strip(comment) 87 62 if VRGet("CN_smbtree","View") = "IconTree" then parent = smbtree.!workgroup; else parent = "" 88 smbtree.!machine = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment)89 63 /* We make any machine as sleeping initially */ 90 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#61:PMWP.DLL") 91 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "ReadOnly", 1) 92 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, NBFH, machine, CommentFH, Comment, WorkGroupFH, CurWG) 64 smbtree.!machine = _AddSleepingMachine(machine,comment,parent) 65 93 66 ok = VRSet( "CN_smbtree", "Painting", 1 ) 94 67 ok = VRSet( "CN_smbtree", "Painting", 0 ) 95 if VRGet("CN_smbtree","View") = "Detail" then do 96 address cmd samba.!nmblookupexe' 'machine' 'debuglevel' -N >'samba.!msg 97 ipstr = "" 98 ip = "" 99 do until lines(samba.!msg) = 0 100 nmblookupline = linein(samba.!msg) 101 if pos(strip(machine)'<',nmblookupline) > 0 then do 102 parse var nmblookupline ip . 103 if pos(strip(ip), ipstr) = 0 then do 104 ipstr = ipstr||ip',' 105 end 106 end 107 end 108 ok = SysFileDelete(samba.!msg) 109 ipstr = strip(ipstr,,',') 68 69 if VRGet("CN_smbtree","View") <> "Detail" then do 70 /* Tree view */ 71 call _RefreshShares 72 end 73 else do /* Fill records for details view */ 74 ok = VRSet("Main", 'Pointer', 'Wait' ) 75 /* Get all IP addresses of the machine */ 76 IPStr = _GetMachineIP(machine) 110 77 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr) 78 parse var IPStr MachineIP ',' . 79 if strip(MachineIP) = "" then MachineIP = machine 80 ok = VRSet("Main", 'Pointer', '<default>' ) 81 82 /* Find out OS, version */ 83 say ' 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'samba.!msg' 1>NUL' 84 address cmd samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'samba.!msg' 1>NUL' 85 smbline = linein(samba.!msg) 111 86 ok = stream(samba.!msg,'c','close') 112 if ip <> "" then do 113 address cmd samba.!smbclientexe' -L "'strip(machine)'" -I "'ip'" -N 'debuglevel' 2>'samba.!msg' 1>NUL' 114 smbline = linein(samba.!msg) 115 ok = stream(samba.!msg,'c','close') 116 parse var smbline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest 117 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS) 118 /* WorkGroupFH, Workgroup */ 119 address cmd samba.!nmblookupexe' -A 'machine' 'debuglevel' -N >'samba.!msg 120 Master = "" 121 do until lines(samba.!msg) = 0 122 nmblookupline = linein(samba.!msg) 123 if pos('<1b>', nmblookupline) > 0 then Master = Master||"LMB," /* + */ 124 if pos('<1d>', nmblookupline) > 0 then Master = Master||"DMB," /* * */ 125 if pos('MAC',nmblookupline) > 0 then do 126 parse var nmblookupline . '=' MAC 127 MAC = strip(MAC) 128 end 129 end 130 Master= strip(Master,,',') 131 ok = stream(samba.!msg,'c','close') 132 ok = SysFileDelete(samba.!msg) 133 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, MBFH, Master,MacFH,MAC) 134 end 135 end 136 else do 137 call _RefreshShares 138 end 139 end 140 when smbtreeline.sl = "" then nop 141 otherwise do 142 say ' Workgroup: "'smbtreeline.sl'"' 87 parse var smbline "Domain=["WorkGroup"] OS=["OS"] Server=["Version"]"Rest 88 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS, VersionFH, Version, WorkgroupFH, WorkGroup) 89 90 /* Find out server role, MAC */ 91 MACRoles = _GetMachineMACRoles(machineIP) 92 parse var MACRoles MAC '|' Roles; drop MACRoles 93 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, MBFH, Roles, MacFH,MAC) 94 if pos("PDC",Roles) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#63:PMWP.DLL") 95 end 96 end 97 when smbtreeline.sl = "" then nop /* skip empty lines */ 98 otherwise do /* possibly a new workgroup */ 99 say ' Possible workgroup: "'smbtreeline.sl'"' 100 /* check for eventual error messages */ 143 101 if pos("RECEIVING",translate(smbtreeline.sl)) > 0 | pos("TDB(",translate(smbtreeline.sl)) > 0 then do 144 102 Msg.Type = "W" … … 146 104 call _ShowMsg 147 105 end 148 else do 106 else do /* it is really a new workgroup */ 149 107 if VRGet("CN_smbtree","View") = "IconTree" then do 150 smbtree.!workgroup = VRMethod( "CN_smbtree", "AddRecord",,, smbtreeline.sl,"#62:PMWP.DLL") 151 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!workgroup, WorkGroupFH, smbtreeline.sl) 152 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!workgroup, "Collapsed", 0) 153 ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!workgroup, "ReadOnly", 1) 154 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', smbtree.!workgroup, "UserData", "WORKGROUP|") 108 smbtree.!workgroup = _AddWorkGroup(smbtreeline.sl) 155 109 end 156 110 CurWG = smbtreeline.sl … … 172 126 _RefreshShares: 173 127 say time()' _RefreshShares() started' 174 /* RefreshID = RANDOM() */ 128 175 129 smbmachine = TempDir||"smbmachine."||machine 176 130 MaxSmbClient = 32 /* Do not run more than MaxSmbClient instances of smbclient.exe at the same time */ … … 195 149 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N' 196 150 197 say ' detach 'samba.!smbclientexe' -L "' strip(machine)'" 'UserCred' 'debuglevel' 1>'smbmachine' 2>NUL'198 address cmd 'detach 'samba.!smbclientexe' -L "' strip(machine)'" 'UserCred' 'debuglevel' 1>'smbmachine' 2>NUL'151 say ' detach 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'smbmachine' 1>&2' 152 address cmd 'detach 'samba.!smbclientexe' -L "'machine'" 'UserCred' 'debuglevel' 2>'smbmachine' 1>&2' 199 153 200 154 if UserCred = '-N' then UserCred = '' … … 213 167 214 168 ok = SysFileTree(Tempdir||'smbmachine.*',smbmachine.,'FO') 215 say ' 'smbmachine.0' file(s) to process.'216 217 169 if smbmachine.0 = 0 then do /* we are done, no more files around, cleanup, disable Timer and exit */ 218 170 RefreshMode = "" 171 ok = VRset("TM_RefreshTreeDisplay","Enabled",0) 219 172 ok = VRSet("CN_smbtree","Enabled", 1) 220 ok = VRset("TM_RefreshTreeDisplay","Enabled",0) 221 ok = VRSet( "CN_smbtree", "Painting", 0 ) 222 ok = VRSet( "CN_smbtree", "Painting", 1 ) 173 ok = VRSet("CN_smbtree", "Painting", 0 ) 174 ok = VRSet("CN_smbtree", "Painting", 1 ) 223 175 say time()' _AddSharesDisplay() completed' 224 176 return /* exit here */ 225 177 end 178 else say ' 'smbmachine.0' file(s) to process.' 226 179 227 180 if UserCred = 'USERCRED' | UserCred = '' | UserCred = '--user=%' then UserCred = '-N' … … 229 182 230 183 do I = 1 to smbmachine.0 231 say ' Going for "'smbmachine.I'"'184 call charout , ' Going for "'smbmachine.I'", got ' 232 185 if VRIsValidObject("DT_STATUSBAR") then ok = VRSet("DT_STATUSBAR","Caption", VRGet("DT_STATUSBAR","Caption")||'.') 233 186 stat = stream(smbmachine.I,'c','open read') 234 187 say '"'stat'"' 188 189 infoline = "" 235 190 if stat = "READY:" then do /* we found a readable output file */ 236 191 OneWorkGroupOnly = 0 237 /* Machine = VRParseFilename(smbmachine.I,'E') */192 238 193 Machine = substr(smbmachine.I,pos('.',smbmachine.I)+1) 239 194 240 195 smbtree.!machine = _GetMachinehandle(Machine) 241 say ' Machine (handle) = "'machine'" ('smbtree.!machine')' 242 196 243 197 if smbtree.!machine = "" then do /* invalid (old) file */ 244 198 say time()' _AddSharesDisplay() exit with Invalid file found (no corresponding machine)' … … 247 201 iterate 248 202 end 203 line = linein(smbmachine.I) /* PID line */ 249 204 line = linein(smbmachine.I) 205 if pos('creating lame', line) > 0 then do 206 line = linein(smbmachine.I) 207 line = linein(smbmachine.I) 208 end 209 if pos('Server=[', line) > 0 then do 210 infoline = linein(smbmachine.I) 211 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest 212 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, OSFH, OS, VersionFH, Server) 213 line = linein(smbmachine.I) 214 end 250 215 say ' Answer "'line'"' 251 216 ok = VRMethod('CN_smbtree', 'SetRecordAttr', smbtree.!machine, 'UserData', "SERVER|"||strip(line)) … … 321 286 wgh = _GetMachinehandle(workgroup) 322 287 if wgh = "" then do /* The machine appears to be in a new workgroup - add it as well */ 323 /* NOTE: This should be obsolete now because the list of available 324 workgroups should always have been updated before we get here */ 325 wgh = VRMethod( "CN_smbtree", "AddRecord",,, workgroup,"#62:PMWP.DLL") 326 ok = VRMethod( "CN_smbtree", "SetFieldData", wgh, WorkGroupFH, workgroup) 327 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "Collapsed", 0) 328 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "ReadOnly", 1) 329 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', wgh, "UserData", "WORKGROUP|") 288 /* NOTE: This should be obsolete now because the list of available */ 289 /* workgroups should always have been updated before we get here */ 290 wgh = _AddWorkGroup(workgroup) 330 291 end 331 292 /* we only do this for machines with empty parent (=workgroup) handle */ … … 339 300 /* There are multiple workgroups, we need additional */ 340 301 /* measures to find out which is our workgroup */ 341 say ' 'samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL' 342 address cmd samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL' 343 infoline = linein(samba.!msg) 344 if word(infoline,1) = "creating" then do /* upcase tables are missing */ 345 say "Missing upcase tables detected!" 302 if infoline <> "" then do 303 say ' 'samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL' 304 address cmd samba.!smbclientexe' -L "'Machine'" -N 'debuglevel' 2>'samba.!msg' 1>NUL' 346 305 infoline = linein(samba.!msg) 347 infoline = linein(samba.!msg) 306 307 if word(infoline,1) = "creating" then do /* upcase tables are missing */ 308 say "Missing upcase tables detected!" 309 infoline = linein(samba.!msg) 310 infoline = linein(samba.!msg) 311 end 312 IF options.!debug == 1 THEN say ' Response = "'Infoline'"' 313 ok = stream(samba.!msg,'c','close') 314 ok = SysFileDelete(samba.!msg) 348 315 end 349 IF options.!debug == 1 THEN say ' Response = "'Infoline'"' 350 ok = stream(samba.!msg,'c','close') 351 ok = SysFileDelete(samba.!msg) 352 353 parse var infoline "Domain=["WorkGroup"] "Rest 316 317 parse var infoline "Domain=["WorkGroup"] OS=["OS"] Server=["Server"]"Rest 318 354 319 wgh = _GetMachinehandle(workgroup) 355 320 if wgh <> "" & VRMethod('CN_smbtree', 'GetRecordAttr', smbtree.!machine, 'Parent') = "" then do … … 358 323 end 359 324 else do 360 /* The machine does not allow browsing and does not report a workgroup */ 361 say ' "'Machine'" does not allow browsing. Unable to determine workgroup.' 362 end 363 end 325 /* The machine does not allow browsing and does not report a workgroup here */ 326 say ' "'Machine'" does not allow browsing.' 327 end 328 end 329 330 ok = VRSet("Main", 'Pointer', 'Wait' ) 331 /* Find out IPs */ 332 IPStr = _GetMachineIP(machine) 333 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, IPFH, IPStr) 334 parse var IPStr MachineIP ',' . 335 if strip(MachineIP) = "" then MachineIP = machine 336 ok = VRSet("Main", 'Pointer', '<default>' ) 337 338 /* Find out server role, MAC */ 339 MACRoles = _GetMachineMACRoles(machineIP) 340 parse var MACRoles MAC '|' Roles; drop MACRoles 341 ok = VRMethod( "CN_smbtree", "SetFieldData", smbtree.!machine, MBFH, Roles, MacFH,MAC) 342 if pos("PDC",Roles) > 0 then ok = VRMethod( "CN_smbtree", "SetRecordAttr", smbtree.!machine, "Icon","#63:PMWP.DLL") 364 343 365 344 say time()' _AddSharesDisplay() success and cleanup' … … 368 347 if ok <> 0 then say ' Failure 'ok' deleting "'smbmachine.I'"!' 369 348 end 370 else say ' Got "'stat'" for "'smbmachine.I'"'371 349 end 372 350 … … 398 376 end 399 377 if match = 0 then rh.I = "" /* return an empty handle, if there was no match */ 378 say ' Handle for "'Machine'" = "'rh.I'"' 400 379 return rh.I 401 380 … … 407 386 if BroadCast = 1 then BroadCast = '-b'; else BroadCast = '' 408 387 409 say 388 say ' 'samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg 410 389 address cmd samba.!smbtreeexe' 'BroadCast' -D 'debuglevel' 'UserCred' >'samba.!msg 411 390 … … 413 392 if UserCred = '-N' then UserCred = '' 414 393 415 drop wgline. 416 417 sl = 0 418 419 do until lines(samba.!msg) = 0 420 sl = sl + 1 421 wgline.sl = linein(samba.!msg) 422 end 423 wgline.0 = sl 424 ok = stream(samba.!msg,'c','close') 425 ok = SysFileDelete(samba.!msg) 426 427 do sl = 1 to wgline.0 428 if pos("RECEIVING",translate(wgline.sl)) > 0 | pos("TDB(",translate(wgline.sl)) > 0 then do 429 iterate /* We ignore errors here */ 430 end 431 workgroup = wgline.sl 394 ok = File2Stem(samba.!msg,"workgroups.") 395 do I = 1 to workgroups.0 396 workgroup = translate(workgroups.I) 397 if pos("RECEIVING",workgroup) > 0 | pos("TDB(",workgroup) > 0 then iterate /* We ignore errors here */ 432 398 wgh = _GetMachinehandle(workgroup) 433 if wgh = "" then do /* A new workgroup was found -- add it */ 434 wgh = VRMethod( "CN_smbtree", "AddRecord",,, workgroup,"#62:PMWP.DLL") 435 ok = VRMethod( "CN_smbtree", "SetFieldData", wgh, WorkGroupFH, workgroup) 436 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "Collapsed", 0) 437 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "ReadOnly", 1) 438 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', wgh, "UserData", "WORKGROUP|") 439 end 399 if wgh = "" then wgh = _AddWorkGroup(workgroup) /* A new workgroup was found -- add it */ 440 400 end 441 401 say time()' _RefreshWorkgroups() done' 442 402 return 443 403 404 /*:VRX _AddWorkgroup 405 */ 406 _AddWorkGroup: procedure expose WorkGroupFH 407 workgroup = arg(1) 408 wgh= VRMethod( "CN_smbtree", "AddRecord",,, workgroup,"#62:PMWP.DLL") 409 ok = VRMethod( "CN_smbtree", "SetFieldData", wgh, WorkGroupFH, workgroup) 410 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "Collapsed", 0) 411 ok = VRMethod( "CN_smbtree", "SetRecordAttr", wgh, "ReadOnly", 1) 412 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', wgh, "UserData", "WORKGROUP|") 413 return wgh 414 415 /*:VRX _AddSleepingMachine 416 */ 417 _AddSleepingMachine: procedure expose WorkGroupFH NBFH CommentFH 418 machine = arg(1) 419 comment = arg(2) 420 parent = arg(3) 421 mh = VRMethod( "CN_smbtree", "AddRecord",parent,, machine||'0D0A'x||comment) 422 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, NBFH, machine, CommentFH, comment) 423 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Icon","#61:PMWP.DLL") 424 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "ReadOnly", 1) 425 ok = VRMethod( "CN_smbtree", "SetRecordAttr", mh, "Collapsed", 1) 426 ok = VRMethod( "CN_smbtree", 'SetRecordAttr', mh, "UserData", "SERVER|") 427 if parent <> "" then do 428 WGName = translate(VRMethod("CN_smbtree","GetRecordAttr",parent,"Caption")) 429 parse var WGName WGName '0D0A'x . 430 ok = VRMethod( "CN_smbtree", "SetFieldData", mh, WorkgroupFH, strip(WGName)) 431 end 432 return mh 433 434 /*:VRX _GetMachineIP 435 */ 436 _GetMachineIP: procedure expose debuglevel samba. 437 /* Get all IP addresses of the machine */ 438 machine = arg(1) 439 say ' 'samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg 440 address cmd samba.!nmblookupexe' 'machine' 'debuglevel' >'samba.!msg 441 ok = file2stem(samba.!msg,"nmblookup.") 442 ipstr = ""; ip = "" 443 do i = 1 to nmblookup.0 444 if pos(strip(machine)'<',nmblookup.i) = 0 then iterate 445 parse var nmblookup.i ip . 446 if pos(strip(ip), ipstr) = 0 then ipstr = ipstr||ip',' 447 end 448 ipstr = strip(ipstr,,',') 449 return IpStr 450 451 /*:VRX _GetMachineRole 452 */ 453 _GetMachineMACRoles: procedure expose debuglevel samba. 454 machine = arg(1) /* May be name or IP */ 455 say ' 'samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg 456 address cmd samba.!nmblookupexe' -A 'machine' 'debuglevel' >'samba.!msg 457 ok = file2stem(samba.!msg,"nmblookup.") 458 Roles = "" 459 MAC = 'xx-xx-xx-xx-xx-xx' 460 do I = 1 to nmblookup.0 461 select 462 when pos('<1c>', nmblookup.I) > 0 then Roles = Roles||"PDC," /* # */ 463 when pos('<1b>', nmblookup.I) > 0 then Roles = Roles||"LMB," /* + */ 464 when pos('<1d>', nmblookup.I) > 0 then Roles = Roles||"DMB," /* * */ 465 when pos('MAC', nmblookup.I) > 0 then do 466 parse var nmblookup.I . '=' MAC 467 MAC = strip(MAC) 468 end 469 otherwise nop 470 end 471 end 472 Roles = strip(Roles,,',') 473 if Roles = "" then Roles = "Workstation" 474 return MAC'|'Roles 475 476 /*:VRX file2stem 477 */ 478 file2stem: 479 msgfile = arg(1) 480 msgstem = arg(2) 481 if right(msgstem,1) <> '.' then msgstem = msgstem'.' 482 say ' file2stem("'msgfile'","'msgstem'")' 483 dyn = 'drop 'msgstem 484 interpret dyn 485 stemcount = 0 486 do while lines(msgfile) > 0 487 stemcount = stemcount + 1 488 inline = linein(msgfile) 489 if pos('creating lame',inline) > 0 then do 490 stemcount = stemcount - 1 491 iterate 492 end 493 dyn = msgstem||stemcount' = inline' 494 interpret dyn 495 end 496 dyn = msgstem||"0 = "stemcount 497 interpret dyn 498 ok = stream(msgfile,'c','close') 499 ok = SysFileDelete(msgfile) 500 drop msgfile msgstem 501 return stemcount
Note:
See TracChangeset
for help on using the changeset viewer.