Page 1 of 1 1
Topic Options
#143816 - 2005-07-19 03:42 PM check for machine name in a file
caradid Offline
Lurker

Registered: 2005-07-19
Posts: 4
Hi all,
I'm not an expert in kixtart,
I want to find how i can check the existence of a worstation name in a file listing them by using the variable @wksta,
instead of using the command below
if instr(@wksta,"kdpp4zp") or instr(@wksta,"kdwn3dw") with a lot of or instructions.
Could somebody help me on this one ?
Thanks in advance.

Top
#143817 - 2005-07-19 03:45 PM Re: check for machine name in a file
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
How many workstation names are in the file?

You could use Readline and place the name of the workstations into an array then ASCAN() to find it.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#143818 - 2005-07-19 03:46 PM Re: check for machine name in a file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
is the file format pre-determined?
or could you just decide to make it ini?

then you could just do something like:
Code:
if ""<>readprofilestring("d:\somePath\wksta's.ini","theMachinesOnWhich I will do this and that",@wksta)

_________________________
!

download KiXnet

Top
#143819 - 2005-07-19 03:59 PM Re: check for machine name in a file
caradid Offline
Lurker

Registered: 2005-07-19
Posts: 4
i have about 130 machine names,i want to check an excel file or csv file to see if the machine executing the script is listed in the file, if in the file i want to run a shell command.
This list of machines will change everyday.
Thank you for your help

Top
#143820 - 2005-07-19 04:04 PM Re: check for machine name in a file
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see the UDF ReadFile(), in the UDF forum.

It will read a file into an array for you, then use ascan as howard suggested
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#143821 - 2005-07-19 05:10 PM Re: check for machine name in a file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
AScan() will only do exact matches and is probably unsuitable for the task.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143822 - 2005-07-19 05:45 PM Re: check for machine name in a file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
One of the ReadExcel() UDFs might return an array that AScan() could work on.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#143823 - 2005-07-20 02:11 PM Re: check for machine name in a file
caradid Offline
Lurker

Registered: 2005-07-19
Posts: 4
i tried this:
if ""<>readprofilestring("c:\test kix\wksta.ini","name",@wksta)
shell "v:\setup\sms\remsms.bat"
endif

in wksta file :
[name]
@wksta = KDWN3DW
@wksta = kdpp4zp

The shell command doesn't run, any idea where i'm wrong ?

Top
#143824 - 2005-07-20 02:34 PM Re: check for machine name in a file
caradid Offline
Lurker

Registered: 2005-07-19
Posts: 4
I found the solution, bad entries in the ini file
[name]
KDWN3DW = @wksta
kdpp4zp = @wksta

and the code to run is :
;Remove SMS Client
$dev = readprofilestring("c:\test kix\wksta.ini","name",@wksta)
if @ERROR = 0
shell "v:\setup\sms\remsms.bat"
endif

Thank you everybody for your help, this forum is very helpfull.

Top
#143825 - 2005-07-20 03:08 PM Re: check for machine name in a file
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh, resourcefull thinking you got there.
actually, the @wksta is not needed in the ini

you could have just said:
[name]
KDWN3DW = 1
kdpp4zp = 1

but now, it actually looks nice.
like expression inside the ini
_________________________
!

download KiXnet

Top
#143826 - 2005-07-20 03:25 PM Re: check for machine name in a file
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
SMS has a remote tool called SMSClean that you can use from a central admin script.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 400 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.069 seconds in which 0.042 seconds were spent on a total of 11 queries. Zlib compression enabled.

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