#81672 - 2003-06-03 02:07 PM
Output to Console
|
PRandal
Fresh Scripter
Registered: 2002-07-17
Posts: 28
|
This one has come up in these forums a few times.
I've been toying with the idea of using KiXtart as a scripting language for Nagios nrpe_nt. Unfortunately the plugins are required to output to the standard console window (not Ruud's emulation of the same).
At the moment I have to use workarounds like this:
code:
REM cpu.cmd @echo off c:\kixtart\kix32 c:\nrpe_nt\cpu.kix type c:\nrpe_nt\cpu.txt
code:
; cpu.kix
$speed=@MHz $phys=MemorySize(0) $sp="" If $speed <> 0 $sp="$speed"+"MHz " endif
$out=$sp+"@CPU $phys"+"MB RAM"+@CRLF
$x=redirectoutput("c:\nrpe_nt\cpu.txt",1) $out
when all I want to do is write to stdout!
Arrrgh!
Ruud, this would be so useful!
We could then do
code:
kix32 stuff.kix > kixout.txt
or better still code:
kix32 stuff.kix | fancyprogram.exe
Please please please give us a simple and effective way of writing to the real CON from KiXtart.
Thanks in advance (but not holding my breath)
Phil [ 03. June 2003, 14:10: Message edited by: PRandal ]
|
Top
|
|
|
|
#81673 - 2003-06-03 03:00 PM
Re: Output to Console
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
The good news is than you can do this. Hurrah.
Add these two lines at the start of your script:
code:
$=SetOption("ASCII","ON") $=SetOption("WrapAtEOL","ON")
Now, you can pipe the output:
code:
kix32.exe myscript.kix | more
Or even redirect it to the console:
code:
kix32.exe myscript.kix >CON:
You will notice that outputting directly to the console is not particularly useful as control characters do not get handled.
|
Top
|
|
|
|
#81674 - 2003-06-03 03:06 PM
Re: Output to Console
|
PRandal
Fresh Scripter
Registered: 2002-07-17
Posts: 28
|
Thanks, that works perfectly.
Phil
|
Top
|
|
|
|
#81676 - 2003-06-03 05:19 PM
Re: Output to Console
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
It was Phils comment about the console being "Ruud's emulation" that sent me down this path.
- KiXtart truncates output to the console if it would wrap - wholly inappropriate for piped or redirected data so you want to switch that off.
- Standard output is in Unicode, which again is not usefull when piping or redirecting output, as you will get two bytes for each character and no application that you are piping to is likely to understand that. Switching to ASCII fixes that problem.
You could probably get away with just switching to ASCII, but I'd recommend both.
|
Top
|
|
|
|
#81681 - 2003-09-07 02:23 AM
Re: Output to Console
|
MCA
KiX Supporter
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Great information, which can't be find on the FAQ forum now.
Good suggestion to put it there too. A manual people aren't reading all the time. For newbies the amount of new information is too much. For oldies they think "the manual doesn't contain new information for me". greetings.
(TIP_how_to_redirect_kix32_output)
|
Top
|
|
|
|
Moderator: Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 514 anonymous users online.
|
|
|