Reputation: 81
Let me say I have something like....
set timeout 10
expect {
"login:" {
send "$USER\r"
exp_continue
}
"assword:" {
send "$PASSWORD\r"
exp_continue
}
$PROMPT {
send_user "Successfully logged in."
}
}
I have a problem with defining the $PROMPT
All these give an error...
set PROMPT {-re ">|:"}
set PROMPT "-re \">|:\""
set PROMPT {-regexp ">|:"}
I get error like...
bad flag "-regexp ":|>"": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
What is the correct way of assigning the variable and (more importantly) what is the concept that I have violated for this error to happen?
Thanking You in advance!
Upvotes: 0
Views: 687
Reputation: 20688
You should write like this:
set PROMPT {>|:}
expect {
-re $PROMPT { ... }
...
}
And to be safer you better define a more precise PROMPT
as some commands may also output chars like >
or :
.
Upvotes: 1