# How to use this expect-lite file, Lines that begin with:
#	'>' send to remote host, implies "wait for prompt"
#	'<' _MUST_ be received from the remote host, or this config script will fail
#	# are comment lines, and have no effect
#	; are printable (in stdout) comments, and have no other effect
#	@ change the expect timeout value
#	! Embedded Expect commands
#	? If statement, use format ?cond?action::else_action
# For more info see: expect-lite.html

#
# Test Basic Functionality of Send '>' '>>' and Expect '<' '<<'
#	Self tested functionality
#
#	Requires Expect-lite version 3.6.0
#

#
# Added additional expects (not expect, fuzzy expect) '-<' '~<'
#
#	Requires Expect-lite version 4.7.0
#



# Turn on warnings
*WARN

# Turn on debug and see the inside workings 
*DEBUG

# set expect timeout
@3

# set bash var NUM
>NUM=5
>TAG="<HTML>"
>TESTSTR="This is an equation:(5+3)/2*2"


; === detect single value with no regex
>echo $NUM
<<5
>
; === detect HTML Tag (no regex using '<<')
>echo $TAG
<<<HTML>
>
; === detect HTML Tag (with regex using '<')
>echo $TAG
<[<]H..L>
>

; === look for no regex with parenthisis, plus, star
>echo $TESTSTR
<<This is an equation:(5+3)/2*2

; === look for wild carding 'This*equation'
# wild card in << no longer supported, too greedy
>echo $TESTSTR
<This.+equation

; === use Regex and escape special chars ()+*
>echo $TESTSTR
<This is an equation:\(5\+3\)/2\*2
>

; === collect equation
>echo $TESTSTR
+$equation=This is an equation:([0-9()/\*+]+)

; === Start BC (which has no prompt)
>bc
<warranty
>>$equation
<<8
>>
>^D
>
*NODEBUG

; === check NOT expect
>echo "the answer is 42"
-<answer is 43

; === check NOT expect of 1 digit
>echo "9"
-<8

*EXP_INFO
; === check variable name starts with underscore (v4.8.1)
$_myvar=underscore
>echo $_myvar
<under
<score



; === test fuzzy expect read var before set
~=$FUZZ

$FUZZ=5
; === test fuzzy expect
~=$FUZZ


; === check fuzzy expect - spaces around number
$MIN=15
>echo "this is the $MIN to rise up"
~<this is the ( 10 ) to rise up
>
>

; === check fuzzy expect - white space at end of line
>echo "cccc is the $MIN		"
~<cccc is the (10)
>
; === check fuzzy expect - hexidecimal
>echo "ffff is the 0xbeef to rise up"
~<ffff is the (0xbeea) to rise up
>
; === check fuzzy expect - decimal
>echo "gggg is the $MIN"
~<(10.5)

; === check fuzzy expect - variable in second parens, not fuzzy
>echo "hhhh 7 the $MIN "
~<hhhh (5) the ($MIN)


; === check fuzzy expect - extra words in parens
>echo "iiii 7 the 10 to rise up"
~<iiii (5) the (10) to rise (up)

; === check fuzzy expect - reverse decimal
>echo "jjjj 12.5 the $MIN to rise up"
~<jjjj ($MIN) the ($MIN) to rise (up)

; === check fuzzy expect - escaped parens
>echo "kkkk (705) the $MIN to rise up"
~<kkkk \(705\) the (10) to rise up

#; === check fuzzy expect - no parens
#>echo "llll now is the time to rise up"
#~<llll now is the time to rise up


; === check fuzzy expect - decimals
# space in front of fuzzy value, and tab after
~= 0.9	
>uptime
~<load average: (0.7)

#; === negative testing
#>echo "zbbb is the ($MIN) to rise up"
#~<zbbb is the ($BAD) to rise up
#
#; === no number
#>echo "zeee is the $MIN to rise up"
#~<zeee (is) the 15 to rise up


#pau!







