Page 1 of 1 1
Topic Options
#140890 - 2005-06-02 04:51 PM Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
I'd like to use command line input in the format used by batch files, but convert the batch file to kix.

e.g. part of my av_stop batch file

sc \\%1 stop "AlertManager"
sc \\%1 stop "McAfeeFramework"
sc \\%1 stop "McTaskManager"
sc \\%1 stop "MCSHIELD"

To run above I could type av_stop machine001

In kix I would seem to have to do:-

KIX32 av_stop.kix $Machine=Machine001

Is it possible to just type:-

KIX32 av_stop.kix Machine001

and read the %1 like you would whilst running a batch file?

thanks

Top
#140891 - 2005-06-02 04:53 PM Re: Command line input
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Is it possible to just type:-

KIX32 av_stop.kix Machine001

and read the %1 like you would whilst running a batch file?




No.

Top
#140892 - 2005-06-02 04:58 PM Re: Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
Richard H

Is it better to use a text file for input and just update the contents as required, and code the kix script to use the readline function?

Andrew

Top
#140893 - 2005-06-02 05:00 PM Re: Command line input
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Better still, use an INI file and ReadProfileString().
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#140894 - 2005-06-02 06:22 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I don't get it, why textfiles, why any files?
why?

if you want it to accept input, why don't you put the input in the format that it accepts?
why you need to go from simple to the hardest possible solution you can find?
_________________________
!

download KiXnet

Top
#140895 - 2005-06-02 09:39 PM Re: Command line input
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Another simple solution would be to do a "gets" from within the script.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#140896 - 2005-06-02 10:42 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no, it's not.
if he wants commandline input, no gets will provide any help!

as a matter of fact, with gets you probably make a script useless as then it waits for user input.
silly.

the point is, the script can be given args on commandline.
just like wants.
and he knows that.
but for some odd reason he does not want to do that but he wants to go on writing some databases and doing some requests to white house for permission to type and so on.

so, currently, I quess all that can be done is let him think for a while what he actually wants.
_________________________
!

download KiXnet

Top
#140897 - 2005-06-03 11:09 AM Re: Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
The reason I wanted to continue to use the batch file command line input style is that I'm not the only user of the scripts and I had wanted to keep the same method of use. I realise it is not much extra work to have to specify the variable and its value at the commandline, but it is different to providing a list of parameters in a certain order.
Top
#140898 - 2005-06-03 01:27 PM Re: Command line input
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You could assign all the params to a single variable and then split it in the script if you wish.

Kix32.exe MyScript.kix $PARAMS="abc 123 def"

Code:
$PARAMS=Split($PARAMS)
For $i=0 To UBound($PARAMS)
"Parameter "+($i+1)+" is "+$PARAMS[$i]+@CRLF
Next


Top
#140899 - 2005-06-03 02:52 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I just wonder... if using the dos way... how do you tell apart the vars?
you would need some sorta specification there too, otherwise you get it messed up?
with kix, you can only give the right parms, as it does not matter what order you use.
and, if you wanna shorten the commandline, you can do:
rename kix-exe to yourScript.exe and rename_your_script.kix to kixtart.kix and place them in same folder. thus you only need to call: 'myScript.exe $params="blaah'

on the other hand, you can always make a bat that calls kix.
_________________________
!

download KiXnet

Top
#140900 - 2005-06-03 03:29 PM Re: Command line input
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
I was thinking it's of more use where the number of parameters is unknown.

Say you have a script to update a computer. You might want to update 1, 2 or who knows how many.

You could call the script one at a time:
Code:
kix32.exe update.kix $COMPUTER=WS001
kix32.exe update.kix $COMPUTER=WS002
kix32.exe update.kix $COMPUTER=WS003



However it makes more sense if you can call the script with any number of parameters:
Code:
kix32.exe update.kix $COMPUTERS="WS001 WS002 WS003 ... WS999"



Equally, you might have options / switches. It's a pain to have to assign each switch to a variable, much easier to do something like:
Code:
kix32.exe myscript.kix $ARGV="-s -t -m WS002 -m WS003 -v5"



Rather than having to remember something onerous like:
Code:
kix32.exe myscript.kix $SILENT=Y $TOP=Y $MACHINE1=WS002 $MACHINE2=WS003 $VERBOSEREPORTLEVEL=5


Top
#140901 - 2005-06-03 03:38 PM Re: Command line input
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Try KixStart.bat.

[Edit... just noticed you just want to put the name, and no "/"... this probably won't work for you.]


Edited by Allen (2005-06-03 03:54 PM)

Top
#140902 - 2005-06-06 02:12 PM Re: Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
I've started trying to use the readfile() function:-

Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=chr(10)
$f=freefilehandle
$_=open($f,$file)
if @error exit @error endif
do $t=$t+readline($f)+$lf until @error
$_=close($f)
$ReadFile=split(substr($t,2),$lf)
EndFunction

I read a text file containing the computer names ok, which I check by displaying the contents of the array, the problem is that I can't seem to assign the value in the array to another variable that is used to query the registry of the required computer. The commented out line is what doesn't work, the line below it works, and is the same computer name as what is in the array.

What am I doing wrong?

$array=readfile('machines.txt')
? $array[0]
; $System = trim($array[0])
$System = '\\NTW0346530\'

This is the sort of thing I'm using the $System for:-

$Key = $System + 'HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\EPOAGENT3000'
$ePO2 = ReadValue($Key, 'Version')

thanks

Top
#140903 - 2005-06-06 02:26 PM Re: Command line input
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Do you have the back-slashes in the file or bare workstation name?
Top
#140904 - 2005-06-06 02:32 PM Re: Command line input
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Code:
$Key = 'HKLM\SOFTWARE\Network Associates\ePolicy Orchestrator\Application Plugins\EPOAGENT3000'
For Each $System In ReadFile('machines.txt')
If Left($System,2)<>"\\" $System="\\"+$System+"\" EndIf
"EPO version for "+$System+": "+ReadValue($System+$Key, 'Version')
Next


Top
#140905 - 2005-06-06 02:35 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, how slow this process can be made?
why not write a form to central administration for each machine you want to use the script with?
_________________________
!

download KiXnet

Top
#140906 - 2005-06-06 02:39 PM Re: Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
Lonkero, I don't understand your post.
Top
#140907 - 2005-06-06 02:41 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I still can't understand why you go with a file way when you originally was looking for a simple way for all admins to use.

the easy way would be a simple kixforms app or commandline version with simple help built in if wrong arg given.
_________________________
!

download KiXnet

Top
#140908 - 2005-06-06 03:03 PM Re: Command line input
awheelhouse Offline
Fresh Scripter

Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
Lonkero

I have two versions of the script, one for single computers and another for multiple computers that uses a text file for input. I thought I would just concentrate on the text file input method, as that seems more difficult for me to get working. What are kixforms apps, and where would I find an example that could help me to understand how to use it for my requirements?

thanks

Top
#140909 - 2005-06-06 03:13 PM Re: Command line input
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, maybe I went too high...
kixforms app examples, see www.kixforms.org

and yes, I understand you are working on textfile method but you still have skipped why you go there.
_________________________
!

download KiXnet

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 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.138 seconds in which 0.081 seconds were spent on a total of 12 queries. Zlib compression enabled.

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