Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


     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

 expect -c  "$expect_do_something"

the error from expect:

  wrong # args: no script following " "solaris" == "solaris" " argument
     while executing
  "if { "solaris" == "solaris" }"
share|improve this question
up vote 1 down vote accepted

Expect, being an extension of Tcl, has to respect Tcl's very few syntax rules. In Tcl, a newline signifies the end of the command (see this rule), so you must put the open brace of the if-body on the same line.

if { "$OS" == "solaris" } {
  # ......................^
  expect -re {#|>} {send ls\r}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.