#!/usr/bin/env bash
# make this auto-runnable! 
# Little bootstrap bash script to run kick start expect-lite script
# Convert --parms to expect-lite param=value format
PARAMS=`echo $* | /bin/sed -r 's;--([a-z]+) ([0-9a-zA-Z]+);\1=\2;g'`
echo $PARAMS
expect-lite r=none c=$0 $PARAMS
exit $?
# 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

#
#	FORK Directive Test
#	Utilizes FORKs to control web client and monitor server log
#
#
#	Requires expect-lite version 3.2.0
#

$wget=wget --no-proxy -O /dev/null http://localhost/
$server_log=/var/log/apache2/access.log


$fork_session=WEB_SERVER

; === get date to match in server log later
> SHDATE=`date +date%Y:%H:%M`
> echo $SHDATE
+$DATE=\ndate(.*)



@10
*FORK $fork_session
; ======== "WEB_SERVER 1a"
>
; === Tail the server log
>tail -f $server_log
# clear the expect buffer
>>

*FORK default
;========== "WEB_CLIENT 2a"
>echo "make web request"
>$wget
<saved
>


*FORK $fork_session
;========== "$fork_session 1b"
>>
<127\.0\.0\.1.*$DATE.*Wget
>^C
>>
>sleep 2


#pau!
