RESOLVED - help please expect send left bracket [ using ssh into a Mikrotik

I have a brain freeze - so I am asking for help

I trying to use a Ubuntu Linux computer to telnet into my Mikrotiks and perform the command:
set [ find default-name=wlan1 ] hw-retries=3

here is part of my expect script where this line is being used:
#
/usr/bin/expect <<EOF | tee TEMP-FILE-Results.txt > logfile.txt
spawn telnet 192.168.33.44
expect “Login”
send “admin\r”
expect “Password”
send “PaSsWoRd\r”
sleep 9
send “interface\r”
sleep 1
send “wireless\r”
sleep 1
send “set [ find default-name=wlan1 ] hw-retries=3\r”
sleep 1
send “..\r”
send “..\r”
send “..\r”
send “..\r”
send “quit\r”
sleep 3
expect eof

My problem is with the left bracket [
Who happens to know the correct escape sequence ?
Thank you for any answers

North Idaho Tom Jones


I ended up using this:
send “set \x5b find default-name=wlan1 \x5d hw-retries=3\r”

I know I’m a bit late here. Regardless, I thought I would post a response anyways, just in case someone else stumbles upon this post, while searching for an answer.
I prefer to use TCL Expect, myself. However, the Syntax is more or less the same, on the “Expect” side.

With that said, the Escape Character in “Expect” is the Backslash Symbol ( \ ).
Therefore, the Command in question, should be re-written, as follows.

send "set \[ find default-name=wlan1 \] hw-retries=3"

However, you might want to just combine the two previous “send” Lines w/ the third (for simplicity purposes), as follows.

send "interface wireless set \[ find default-name=wlan1 \] hw-retries=3\r"