#!/usr/bin/env bash
# make this auto-runnable! 
# Little bootstrap bash script to run kick start expect-lite script
# determine OS (Mac, Linux, cygwin)
OS=`uname -s`
HOST=localhost
case $OS in
	"Linux" )       SED_OPT=" -r ";;
	"Darwin" )      SED_OPT=" -E ";;
	"CYGWIN_NT-5.1" )   HOST=none;   
						SED_OPT=" -r ";;
	* )				echo "Error: Unknown OS:$OS"
					exit 1;;
esac
# Convert --parms to expect-lite param=value format
PARAMS=`echo $* | /bin/sed $SED_OPT 's;--([a-zA-Z_]+) ([0-9a-zA-Z]+);\1=\2;g'`
echo $PARAMS
$HOME/bin/expect-lite r=$HOST 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

#
#		OLS 2010 Example Script by Craig Miller, July 2010
#
#		Web Client & Server Identification
#
#
#
#




# set timeout to 10 seconds
@10
#Get sudo password from env variable 
$SUDO_PASS=$EL_rootpass
$WEB_SERVICE=http://www.w3.org/
$WEB_SERVICE=http://www.linuxsymposium.org/

# start packet capture
*FORK tcpdump
>echo $SUDO_PASS | sudo -S tcpdump -i eth0 -s 256 -e -X portrange 80 | egrep -A 10 'org.www'

# force expect-lite to wait until tcpdump is ready
<\nlistening on
<link-type

# initiate web request with wget
*FORK wget
; === get page without saving a copy, show HTTP headers
>wget -S --spider $WEB_SERVICE
# verify server in wget output
<<Server: Apache
; === Pause to break
>sleep 2
>

# check packets captured
*FORK tcpdump
# verify client
<User-Agent
<Wget
# verify server
<Server
<Apache/2
>>^C
; === Pause to break
>sleep 2
>

#*INTERACT

>>
>


 

