#36884 - 2003-02-25 06:10 PM
Compound InStr.....
|
ArchAngel96
Getting the hang of it
Registered: 2002-10-20
Posts: 70
|
When people logon at work, I need to see what machine name it is and then do or don't run a scan base on the computer name. My real problem is that I need to check for a varity of varibles in the computer name...
Each computer is named for its location and then its function at that location: S0100N01. The first four numbers changer per location and of course the last three characters, both the letter and the two numbers change.
I know what I don't want to scan for, so everything else I do. the problem is the variables Example: Locations 0002 - 0598 with: S01 R01 V01 H01 - H10 N01 - N24 I don't want to scan, but any thing at location 0800 I want to scan. And lastly, nothing at location 0900 should be scanned.
I'm looking at having to write something like: code:
If NOT (InStr(@WKSTA,'0002') AND InStr(@WKSTA,'S01')) OR InStr(@WKSTA,'0900') OR (InStr(@WKSTA,'0425') AND InStr(@WKSTA,'R01'))
but with all the variables in there, which will make a very long line....
Is there a better way of doing this, or am I going to need to write out this line for every combination? and can that even be done? [ 25. February 2003, 18:11: Message edited by: ArchAngel96 ]
_________________________
penny = the target
the playing field = three football fields side by side
you = only allowed to stand on the outside of the playing field
tool you get to use to find the penny = a ONE INCH LAWN DART
get the level of difficulty?
|
|
Top
|
|
|
|
#36886 - 2003-02-25 06:15 PM
Re: Compound InStr.....
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
Look at using ASCAN() and rethink your logic. Create an array containing the two digit codes and a second one contianing the four-digit codes. Then check the first two digits of the computername and then the four-digit ones.
code:
$two='S01','R01' $four='0425','0900' if ascan($two,left(@WKSTA,2))=-1 and ascan($four,left((@WKSTA,4))=-1 ; not in either array else ; in at least one fo the arrays endif
[ 26. February 2003, 15:48: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
|
Top
|
|
|
|
#36887 - 2003-02-25 06:16 PM
Re: Compound InStr.....
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Have you considered a solution based on logical subnet instead of the computer name?
|
|
Top
|
|
|
|
#36889 - 2003-02-25 07:43 PM
Re: Compound InStr.....
|
ArchAngel96
Getting the hang of it
Registered: 2002-10-20
Posts: 70
|
To answer Lonkero: Basically, we want to scan everything else... We know exactly what we don't want to scan, but we also want to check to make sure our field techs are naming computers correctly, no one is Brining in their own computers and some how getting them on our network. And as far as the 'want to scan' not all the machine names exist at each location. Therefore the easiest solution is to 'not scan' my list, then everything else will get scanned.
To answer Howard Bullock: No actually, I didn't consider that. But we already have a way to separate certain machines in our enviornment within the logon.bat(kix) and so I was simply attempting to follow the same path... Oh, and as new locations are added, 'Someone' (most likely me) would have to update that list every time...
AS for sealeopard: I think an array, as you gave an example, would be the easiest. Thou, I would still have to update the array info, but I wouldn't have to worry about the IP chaning at the location... sometimes this does happen for all the right reasons... By using the array, I can simply adjust the location numbers to include the new locations, or remove them as they fall off.
I haven't used an array before, can anyone recommend some good examples that could help....? Thanx
_________________________
penny = the target
the playing field = three football fields side by side
you = only allowed to stand on the outside of the playing field
tool you get to use to find the penny = a ONE INCH LAWN DART
get the level of difficulty?
|
|
Top
|
|
|
|
#36892 - 2003-02-26 11:02 AM
Re: Compound InStr.....
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
If you want to keep it simple this should do it for you:
code:
$sLocation=SubStr(@WKSTA,1,5) $sFunction=SubStr(@WKSTA,6,3) $iScan=0 ; Default is to not scan. Select Case $sLocation >= "S0002" AND $sLocation <= "S0598" Select Case $sFunction = "S01" Case $sFunction = "R01" Case $sFunction = "V01" Case $sFunction >= "H01" AND $sFunction <= "H10" Case $sFunction >= "N01" AND $sFunction <= "N24" Case "true" $iScan=1 ; None of the above? Then scan EndSelect Case $sLocation = "S0800" $iScan=1 ; Scan all 0800 locations Case $sLocation = "S0900" $iScan=0 ; Don't scan 0900 locations Case "true" $iScan=1 ; Scan unknowns. "***WARNING*** Badly formed workstation name '" + @WKSTA + "'" + @CRLF EndSelect If $iScan ; *** YOUR SCANNING CODE HERE *** EndIf
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 837 anonymous users online.
|
|
|