#140890 - 2005-06-02 04:51 PM
Command line input
|
awheelhouse
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
   
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
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
|
|
|
|
#140897 - 2005-06-03 11:09 AM
Re: Command line input
|
awheelhouse
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
   
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
|
|
|
|
#140900 - 2005-06-03 03:29 PM
Re: Command line input
|
Richard H.
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
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
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
|
|
|
|
#140904 - 2005-06-06 02:32 PM
Re: Command line input
|
Richard H.
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
|
|
|
|
#140906 - 2005-06-06 02:39 PM
Re: Command line input
|
awheelhouse
Fresh Scripter
Registered: 2005-06-02
Posts: 11
Loc: Leeds, UK
|
Lonkero, I don't understand your post.
|
|
Top
|
|
|
|
#140908 - 2005-06-06 03:03 PM
Re: Command line input
|
awheelhouse
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 640 anonymous users online.
|
|
|