anziotest/answerback - Brian K. White - brian@aljex.com - Aljex Software This is intended to provide a way to test if the user is using some version of anzio for their terminal emulator by sending special escape sequences that only anzio will react to in a predictable way. This is necessary because we need to know what kind of "run-program" escape codes to send to the terminal, if any, and in some cases, such as linux's telnet server and all ssh servers i've met so far, the server daemon does not negotiate the environment variables the cient attempts to send, other than a few basics like $TERM, so we cannot count on arbitrary variables like $ANZIO. the code is based on this discussion board post: http://www.ale.org/archive/ale/ale-1996-10/msg00153.html by "Eric Z. Ayers" run anziotest without redirecting stdout. you may redirect stderr if you want (no need to though). anziotest will send special escape sequences that only anzio will react to. then it will read stdin up to the first newline. then it will print the input buffer to stderr. if no input was received it will print nothing on stderr and it will exit with status 1. If any input was received it will be printed on stderr and it will exit with status 0. after it has sent the escape sequence to the terminal, it will only wait up to N number of seconds for a response before giving up, where N is a compile-time configurable option. The default is 1 second. If the user is using anzio for their terminal emulator, anzio will recognize the escape sequence sent by anziotest and will send back it's version number. If the user is using anything else the sequence will be ignored. because there will be a N second delay for anyone not using anzio, only run this once in /etc/profile or ~/.profile Also because of the possible delay, try to avoid running this test in the first place by testing for $FACETTYPE and $ANZIO variables first, if either is defined, then you don't need to run anziotest. You must not redirect anziotest's stdout. for anziotest to work, it's stdout needs to be sent to the terminal emulator client. Sample use in /etc/profile to simply test for the presence of any version of anzio: [ -z "$ANZIO$FACETTYPE" ] && anziotest 2>/dev/null && ANZIO=true [ -n "$ANZIO" ] && export ANZIO Sample that tells you Anzio's version number (but not lite vs win): [ -z "$ANZIO$FACETTYPE" ] && { ANZTMP=/tmp/anz$$ anziotest 2>$ANZTMP && ANZIO=`cat $ANZTMP` rm -f $ANZTMP } [ -n "$ANZIO" ] && export ANZIO Also included is a more general-purpose tool called answerback. it works exactly the same way as anziotest, with the exception that answerback sends a single Ctrl-E (ascii chracter 005) instead of an anzio-specific escape sequence. Many terminals respond with *something* when sent this, but they don't all react the same way, and some don't react at all. PuTTY for instance, will send back "PuTTY" by default, or you can configure it to return anything you want. Facetwin on the other hand will only beep. (FacetWins way of saying "emulation error"). Yet another type of reaction is xterm, which sends back a terminal ID escape sequence of the type used by the program "qterm". Here is a sample usage of answerback (suitable to be placed into /etc/profile or ~/.profile). It sets the variable TERM_PROG to whatever the terminal sent back, if anything. [ -z "$ANZIO$FACETTYPE" ] && { ABKTMP=/tmp/anz$$ anziotest 2>$ABKTMP && TERM_PROG=`cat $ABKTMP` rm -f $ABKTMP } [ -n "$TERM_PROG" ] && export TERM_PROG