Page 1 of 1 1
Topic Options
#80785 - 2002-04-29 03:19 PM Switch for running commandline parm as script
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Ruud, could you include a switch that would permit us to execute a string as a program from the command line?

Example: Kix32 /p "for $i=1 to 5 ? 'Hello World' next"

This would permit us to execute programs without creating a file and then having to clean up afterwards.

[ 29 April 2002, 15:20: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#80786 - 2002-04-29 03:44 PM Re: Switch for running commandline parm as script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
If we could pipe the script in (previously requested), this would also deal with the issue.

Of course piping (at least on some versions of windows) is crippled, and is simply emulated by the operating system creating a temporary file.

The benefit of piping is that you can submit large files.

Of cource there is no reason that you cannot create a simply script called "execute.kix" which contains the line:
code:
Exit Execute($Script)

then call it as:
quote:
Kix32 execute.kix $Script="for $i=1 to 5 ? 'Hello World' next"

Top
#80787 - 2002-04-29 04:07 PM Re: Switch for running commandline parm as script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Just an fyi, kix does have limited support for input piping, here's an example:

Create a file called test.dat with five rows:

1
2
3
4
5

Create a script called test.kix like this:

break on

while @error = 0
 gets $x
 if $x = "$$x"
  quit(1)
 endif
 ?$x
loop

exit 1


Run the whole thingy like this:

c:\> type test.dat | kix32 test.kix

-Shawn

Guess you could code it like this too:

break on

gets $x
while $x <> "$$x"
 ?$x
 gets $x
loop

exit 1


--Shawn

[ 29 April 2002, 16:13: Message edited by: Shawn ]

Top
#80788 - 2002-04-29 04:53 PM Re: Switch for running commandline parm as script
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Shawn,
Yeah, been there, tried that. As you've seen it assigns the variable name as the value if there is no input, which I guess is a feature of it reading past memory rather than an intended action. That means it's unreliable.

In fact it seems to assign something odd. From memory if you run it with no piped input you get another bit of the script.

There are another couple of problems.
1) GET doesn't work the same way, which might be a bonus (see 2)
2) There is no way to re-attach the input stream (maybe write a udf wrapper using GET instead - See 1)
3) Specific to this thread, you have to have the "read/execute" script in place anyway.

As it is an undocumented feature and a bit flakey to boot I wouldn't recommend its use at present.

I was playing with the "C" "popen()" call, to see If I could pipe the script in to avoid creating a temporary file for KiXcrypt, but the process is just not reliable enough.

Sorry Howard, we seem to have hijacked your thread.

Top
#80789 - 2002-04-29 05:03 PM Re: Switch for running commandline parm as script
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Not a problem. All interesting ideas. I still like the switch idea. I am starting to dislike the perpetual workaround business though.

Anyway you are keeping the thread at the top of the active list where my inital post may get noticed more. [Smile]

[ 29 April 2002, 17:17: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#80790 - 2002-04-29 05:12 PM Re: Switch for running commandline parm as script
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Right on, I just threw that input pipe thingy out as an FYI. Writing a script that can execute kix scripts through an input pipe would be overkill anyways - a script like Richards kixcrypt would be an exception. But getting back to your idea. An added bonus would be if kix's output pipe (which doesn't work at all) was working. That way you could pass a script string on the cmdline and pipe the results to another application, or at least get the output into a file without having to code open/write/closes in your code string, eh ?

-Shawn

hmmm... guess you could put a redirectoutput in there somewheres. anyways, I kinda miss the old input/output redirection - which used to work in version 2.x or 3.x long, long time ago.

[ 29 April 2002, 17:14: Message edited by: Shawn ]

Top
#80791 - 2002-04-29 05:29 PM Re: Switch for running commandline parm as script
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
I like the idea of running kix32.exe in command mode. You could either have:

kix32.exe /p "command"

or

kix32.exe /cmd

This would start a commandline session that would allow you to type in and execute code a line at a time (REXX allows this). alternately, you could do a

kix32.exe /cmd /out="C:\test.kix"

This would allow you to save the actual lines that you are testing to an output file. The "ESC" key could always be used to cancel out and end the commandline execution.

Brian

Top
#80792 - 2002-04-29 05:34 PM Re: Switch for running commandline parm as script
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Hmm. After thinking about it... it might be better to do it like this:

KIX32.EXE /C "commandline"

Or

KIX32.exe /K "commandline"

to allow you to continue typing in commands.

Or as I mentioned before:

KIX32.EXE /CMD (or without switch) to run in command mode.

Brian

Top
#80793 - 2002-04-29 08:42 PM Re: Switch for running commandline parm as script
New Mexico Mark Offline
Hey THIS is FUN
****

Registered: 2002-01-03
Posts: 223
Loc: Columbia, SC
I'd like something like this as well. It would necessarily have to be pretty limited. For instance, it would be difficult to support multi-line commands interactively. And UDF's would be out. But just having a way to test simple code fragments would be nice.

The piping solution might be better, as the code could be read in completely before execution started, so parsing could be done as with a script file.

New Mexico Mark

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

Generated in 0.058 seconds in which 0.024 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