Page 1 of 1 1
Topic Options
#170448 - 2006-11-20 05:48 AM New Switch to support Free style Command Line arguments
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Currently, kix32.exe only accepts variables in the format of $var="blah", a few predefined switches, and/or additional script names as arguments. If you try to provide any other type of argument, it causes an error.

With the current addition of the getcommandline() function, I would like to suggest adding another switch to kix32.exe that would allow you to use your own structure for arguments. For example:
Code:

kix32 /o script.kix [Open/Other arguments]


Once the /o switch is set to kix32.exe, it would allow the user to define variables in the format they choose, and they would have to handle the variables in the code via the getcommandline() function.




In the mean time I did find a workaround that would allow some degree of open arguments, but it requires that the script end with "Quit" to keep it from trying to run the arguments as scripts. For example:

kix32 script.kix 1234567890 abc edf

Code:
 
break on
for each $arg in getcommandline(1)
? $arg
next

quit 0


Returns:
Quote:


kix32
script.kix
1234567890
abc
edf




Top
#170449 - 2006-11-20 07:24 AM Re: New Switch to support Free style Command Line arguments
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well I'm not trying to squash your idea, but curious how you really use this behavior in day to day tasks.

This seem almost more like batch files, ie.. I don't call too many options like that myself. I call a lot of scripts from the command line but they almost all are self contained or call other UDFs on their own.

Are you wanting to support some type of modular library by command line?
 

Top
#170450 - 2006-11-20 07:40 AM Re: New Switch to support Free style Command Line arguments
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
Personally, right this minute, I have no immediate use for it, however in the past I would have like to have been able to do it this way. I've seen numerous other posts asking for a way to do it, and even vbscript supports it. I guess I look at the way Kixtart does arguments as limiting, and with the addition of the getcommandline function, now it just seems like an easy fix to allow that flexablity.
Top
#170451 - 2006-11-20 07:45 AM Re: New Switch to support Free style Command Line arguments
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
me too.
Top
#170452 - 2006-11-20 10:02 AM Re: New Switch to support Free style Command Line arguments
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
No need for the Quit:

Code:
Break On
For Each $arg in GetCommandline(1)
If Left($arg,1)="$$" "Argument: "+SubStr($arg,2)+@CRLF EndIf
Next



You just need to prefix your switch with a "$". Consider the following, which in order comprises a simple switch, a complex switch with a parameter and a bare parameter value:
Quote:

C:\Temp>kix32 cl.kix $/s $/p:"A switch with a parameter" $asimpleparameter
Argument: /s
Argument: /p:A switch with a parameter
Argument: asimpleparameter




Using the "/" means that there is no chance of a variable namespace clash.

Top
#170453 - 2006-11-20 10:12 AM Re: New Switch to support Free style Command Line arguments
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
imho, all non kix switches should be allowed to pass.

using some sort of $ thingie like shown above does work, but makes it harder than it needs to be.

Top
#170454 - 2006-11-20 01:45 PM Re: New Switch to support Free style Command Line arguments
Benny69 Offline
Moderator
*****

Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
I like the idea.
This probably does not work right now, but it seams more intuitive:
Code:

$args = split(GetCommandline(),"/")



Edited by Benny69 (2006-11-20 02:26 PM)
_________________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)

Top
#170455 - 2006-11-21 08:54 PM Re: New Switch to support Free style Command Line arguments
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Hey Doc!

I can't count (on both hands and feet!) the number of Kix scripts I have that need Bat files to feed command line args to them!

In fact, thinking about it, I have more scripts that work using (sometimes optional) command line args than those that don't.

Just my experience...

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#170456 - 2006-11-21 09:43 PM Re: New Switch to support Free style Command Line arguments
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Yes, but we know you come from a different background

I'm not saying one can't use or come up with ideas, methods for it's use, just curious why/how normal admins would use it.

I've been scripting now for quite a while and I've so far managed to run my scripts without it. Doesn't mean maybe I couldn't be more efficient though I suppose, just most scripts are one offs. Those that run often are typically already either part of Logon script, or the script contains all it needs to know to complete the task.

But hey if there is a real need for it then that's great, I hope Ruud listens to the suggestion.
 

Top
#170640 - 2006-11-24 11:08 PM Re: New Switch to support Free style Command Line arguments [Re: NTDOC]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Just played with this.. quite handy, actually.

I associated .KIX with Kix32.exe. When I edit the OPEN association in the registry and change the command from:
c:\local\bin\kix32.exe "%1"
to:
c:\local\bin\kix32.exe "%1" "%*"

I can create a kix script and invoke it like any other bat or exe file:
Code:
KixScript -a -q -362

will return an array of 3 elements. The first element is the path to the kix32 executable (C:\local\bin\kix32.exe), the second is the path to the script (C:\work\test.kix), and the third is all the command line args (-a -q -362).
The third arg can be split and parsed easily.

I have experienced Allen's issue - the last line of the script must be a Quit 0 - a small price to pay for this feature. The mod that Les offered only seems to work if you continue to use the $VAR=value method, although it does not require the quit.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#170641 - 2006-11-25 12:58 AM Re: New Switch to support Free style Command Line arguments [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Huh? What did I do?

If I were rich, I could understand mixing us up but I am poor.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#170683 - 2006-11-26 01:05 AM Re: New Switch to support Free style Command Line arguments [Re: Les]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
No! Not you, Les! The "other" Les! - er - Richard!

(sorry - I thought it was safe to post with the problem juggling dropped to 6 or 7 items. Apparently, I was mistaken!)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171280 - 2006-12-09 06:06 PM Re: New Switch to support Free style Command Line arguments [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
I see that the followup post has disappeared..

After additional experimentation, I found that if you add a "/' before the "%*", the Quit 0 is not required. The down side is that you have a leading null "/"

The registry key I mentioned earlier can be defined as: c:\local\bin\kix32.exe "%1" "/%*"

By doing this, you can run a Kix script with any kind of command line args - for example - BedRock.Kix /Flintstones Fred Wilma Barney Betty, and GetCommandLine(0) will return:
"C:\local\bin\kix32.exe" "K:\Misc\cl.kix" "/ /Flintstones Fred Barney Wilma Betty"

You can easily trim the leading "/ " and get the args you need.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#171281 - 2006-12-09 06:25 PM Re: New Switch to support Free style Command Line arguments [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
cool.
_________________________
!

download KiXnet

Top
#185733 - 2008-02-26 06:52 PM Re: New Switch to support Free style Command Line arguments [Re: Lonkero]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
I love this idea, when i am at a remote site on our domain i dont like to sit there for 5 minutes waiting for drives,printers,etc to map. I can use this as a kill switch of sorts, prompting to ask if i want to do certain tasks or not.

 Code:
Break On
For Each $arg in GetCommandline(1)
	If Left($arg,1)="$$"
	$cmd_arg=SubStr($arg,2)
	EndIf

  if $cmd_arg='administrator'
	? "ITS OVER NINE THOUSAND"
  endif
Next

Top
#185734 - 2008-02-26 07:21 PM Re: New Switch to support Free style Command Line arguments [Re: duo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
5 minutes for a login script??! Something's gotta be wrong there. Even at our small branch offices with a 256K Frame connection, it takes no more than about 20 seconds to decide on up to 21 drive connections based on 39 group or OU membership comparisons.

You might want to revisit the logic if a login script takes that long!

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185736 - 2008-02-26 07:28 PM Re: New Switch to support Free style Command Line arguments [Re: Glenn Barnas]
duo Offline
Getting the hang of it

Registered: 2007-10-25
Posts: 61
Loc: iowa
maybe, but hopefully your not trying to map a drive to servers 10 miles away from the location. The logic is not the problem its just windows. In house it takes approx 3-4 seconds

Edited by duo (2008-02-26 07:28 PM)

Top
#185745 - 2008-02-26 09:46 PM Re: New Switch to support Free style Command Line arguments [Re: duo]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
We have several hundred branches, all over the US, which communicate to servers here in NJ. No branch has its own file server - so, yes, we're communicating with sites more than 10 miles away. ;\) The branches use Frame Relay links for communication, with the smallest branches using 256Kbps channels (128K nominal, 256Kbps burst). The Kix32 loads from the NetLogon share, so the time includes loading Kix, the script, and the config file.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.072 seconds in which 0.027 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