I'm trying to write an expect script, which is based on Tcl. (actually I'm trying to generate expect scripts in python, and no, I can't use pyexpect)
How can I send a string without special characters (like [
) being interpreted as commands?
In bash shell, I can use single quotes to write raw strings.
$ echo 'hello $world'
hello $world
But with expect, I have many problems with special characters. For example, brackets are interpreted as commands.
expect1.1> send_user "[hello]"
invalid command name "hello"
while executing
"hello"
How can I just print the string "[hello]"?
EDIT: just enclosing a string in curly braces doesn't always work.
For example
expect1.4> send_user {h}ello}
doesn't print the string "h}ello". It gives an error:
extra characters after close-brace
while executing
"send {h}ello}
And there is no way to escape the curly braces according to the doc.
Or what if I want to send a string starting with *} ? Rule 5 in http://tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M10 will interfere and no way to escape the * or the }.