Page 1 of 1 1
Topic Options
#81672 - 2003-06-03 02:07 PM Output to Console
PRandal Offline
Fresh Scripter

Registered: 2002-07-17
Posts: 27
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 Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
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 Offline
Fresh Scripter

Registered: 2002-07-17
Posts: 27
Thanks, that works perfectly.

Phil

Top
#81675 - 2003-06-03 04:06 PM Re: Output to Console
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
w0w!
what those 2 lines have to do with the piping itself?

as far as I see it, they are just formatting commands, no?
_________________________
!

download KiXnet

Top
#81676 - 2003-06-03 05:19 PM Re: Output to Console
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4945
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
#81677 - 2003-06-03 05:44 PM Re: Output to Console
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
very nice, very, very nice. this should be documented and highlited seperately in the kixtart manual.
Top
#81678 - 2003-06-03 07:30 PM Re: Output to Console
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11577
Loc: CA
Or at least in the FAQ here on the board.

Kent, Les Can one of you guys look at adding this to either one of the other FAQs or one of its own.

Thanks.

Top
#81679 - 2003-06-03 07:31 PM Re: Output to Console
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
DOC,
It was your idea... you do it! [Big Grin]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81680 - 2003-06-03 07:43 PM Re: Output to Console
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
uhm, from the very first initial post I understood that piping is not possible. [Confused]

phil, why are you and other guys confusing me! [Frown]
_________________________
!

download KiXnet

Top
#81681 - 2003-09-07 02:23 AM Re: Output to Console
MCA Offline
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)
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#81682 - 2003-09-08 12:16 AM Re: Output to Console
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
now, the documentation about this should also make clear that this only works with the old console version of kix.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 142 anonymous users online.
Newest Members
KatieQuinn, Brennnnn, MKubicsek, xguixa, mdress
17681 Registered Users

Generated in 0.036 seconds in which 0.012 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