Page 1 of 1 1
Topic Options
#194304 - 2009-06-18 01:18 AM jumping sections of a script / excluding workstations
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
I konw there is a much better way to do this but just don't have the experience to know. I'd like to make an exclusion list so I don't run certain parts of my script on specified workstations

IF NOT @WKSTA = "Workstation1" OR "Workstation2" OR "Workstation3" OR "etc"
RUN SOME COMMAND
ENDIF

Top
#194305 - 2009-06-18 01:56 AM Re: jumping sections of a script / excluding workstations [Re: jeff_eisenberg]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4378
Loc: USA
One way...
See ComputerInGroup() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84539

 Code:
If ComputerInGroup("SomeGroupName",@domain)
  ;do stuff
Endif


Edited by Allen (2009-06-18 01:57 AM)

Top
#194306 - 2009-06-18 02:21 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
What if I want to include the computer names within the script?
Top
#194307 - 2009-06-18 02:31 AM Re: jumping sections of a script / excluding workstations [Re: jeff_eisenberg]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4378
Loc: USA
You asked for a better way... \:\)
Top
#194308 - 2009-06-18 02:43 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
So I tried the syntax below but it only seems to register the first entry "Workstation1". Is there some reason the script would not pay attention to the following entries after "Workstation1"? In other words, it runs the command if it is run on Workstation2, 3, etc.

IF NOT @WKSTA = "Workstation1" OR "Workstation2" OR "Workstation3" OR "etc"
RUN SOME COMMAND
ENDIF

Top
#194309 - 2009-06-18 02:45 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4378
Loc: USA
Okay... maybe this way then?

Create an INI file and use EnumINI() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=135385

untested:
 Code:
$excludedcomputers=EnumINI("File.ini")
if ascan($excludedcomputers,@wksta)=-1
  ;not in the excluded list, so do stuff
else
  ;found the excluded computer, so skip this section
endif

Top
#194310 - 2009-06-18 02:52 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4378
Loc: USA
The problem with what you are doing is, you are creating a mess and don't realize it.

what you are asking for is something like...

if @wksta="Workstation1" or @wksta="Workstation2" or @wksta="Workstation3"

...but when you start sticking Not in front of those with OR... the results are going to be something other than what you are expecting, not to mention hard to follow.

Top
#194311 - 2009-06-18 03:03 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4378
Loc: USA
I think this will work... not tested.

 Code:
if not(@wksta="Workstation1" or @wksta="Workstation2" or @wksta="Workstation3")
  ;do stuff
endif


I hate this kind of code... my eyes cross and then I question what I did... if its right... Anyone else care to jump in here.

Top
#194312 - 2009-06-18 06:43 AM Re: jumping sections of a script / excluding workstations [Re: Allen]
jeff_eisenberg Offline
Fresh Scripter

Registered: 2009-02-26
Posts: 45
Loc: CA
Thanks Allen,

As bad as it is, at least I see where my syntax was wrong.

JEff.

Top
#194313 - 2009-06-18 10:51 AM Re: jumping sections of a script / excluding workstations [Re: jeff_eisenberg]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
Loc: Leatherhead, Surrey, UK
If you don't want to use external (ini) file then a simpler and more manageable way of implementing exclusion lists is with arrays:
 Code:
$aExclusionList_1=Split("Workstation1,Workstation2,Workstation3",",")

If 1+AScan($aExclusionList_1,@WKSTA)
	"Workstation "+@WKSTA+" is in exclusion list"+@CRLF
Else
	"Workstation "+@WKSTA+" is not in exclusion list"+@CRLF
EndIf

Top
#194314 - 2009-06-18 12:11 PM Re: jumping sections of a script / excluding workstations [Re: Richard H.]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 669
Loc: Maryland, USA
I think Allen's first idea was the best. By creating a group and putting the computers you want to exclude in it, you just need to set up your script once. Later if you need to add another system, or remove one, you don't have to change your script. Rather, you just add or remove a computer from the group. I think it is much cleaner and easier to maintain.

Regards,

Brad

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 37 anonymous users online.
Newest Members
FlyHorton, mschwj, Barchester, Evgeniy, kvanacker
17498 Registered Users

Generated in 0.035 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org