View Single Post
Old 07 July 2015, 14:38   #38
BigFan
Registered User
 
BigFan's Avatar
 
Join Date: Feb 2014
Location: Germany
Posts: 261
Return code checking

A very simple way to check your code is to periodically ask the value of one
of both of the internal variables "RC" and "RESULT".
RC keeps track of all commands, functions both internal and external.
RESULT stores the message, the current host replied when sending a command.

The content of RESULT heavily depends on whom we talked to.
While RC always represents a positive numeric value of 0 or higher,
RESULT can store anything from numbers to strings to nothing.
To make use of RESULT, enable it by calling "Options RESULTS" before
results are received. Place on top of script for general purpose.
If RESULT wasn't returned the symbol becomes a string. E.g.:

Adress fcheck.1 Log
Logfile = RESULT /* assume result is a string like "20150701-1002-entry.45-kill"*/ then
Code:
Logfile = "20150701-1002-entry.45-kill"
But if addressed host is offline, or Options Results is not set ,
RESULT becomes a string itself
Code:
Logfile = "RESULT"
Never do a boolean check for RESULT !

Use 'Say rc' or 'Say result' to display them in current console, or redirect them
anywhere you like, e.g. in a log file, pipe, clipboard, conbuffer. Be more precise
and place a string as explanation next to it.
One or two return codes or results aren't big problem. 24 or hundreds of them
and you start pulling your hair

Last edited by BigFan; 07 July 2015 at 15:56.
BigFan is offline  
 
Page generated in 0.04589 seconds with 11 queries