expect script + write "if" in expect script

view story

http://serverfault.com – please advice what's wrong with my exepct syntax ( I run expect in ksh script on Solaris 10 machine ) I want to verify if OS is linux so if it true the expect check if prompt is "#" or ">" and then run the "ls" command but I get the error below please advice what could be the problem OS=solaris expect_do_something=`cat << EOF set timeout -1 spawn telnet 0 $IP_ADDRESS expect login: {send $LOGIN\r} expect Password: {send "$PASS\r"} if { "$OS" == "solaris" } { expect -re {#|>} {send ls\r} } expect eof E (HowTos)