Answer the question
In order to leave comments, you need to log in
How to properly use escaping in bash?
Hello
I'm tormenting the expect script to automate the telnet action.
This script works, although not perfectly:
#!/usr/bin/expect
spawn telnet-ssl
expect ">"
send "set crlf\r";
expect ">"
send "open 192.168.1.201\r";
expect ''
send "cd online\r";
expect ''
send "nc 216.146.43.71 80 > 192.168.1.201.ext.ip\r";
expect ''
send "tftp -s -l 192.168.1.201.ext.ip 192.168.1.2\r";
expect ''
nc 216.146.43.71 80 | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}' > 192.168.1.201.ext.ip
Answer the question
In order to leave comments, you need to log in
The point is that quotes (by default) interpret special characters $ \ ` . That is, the backslash in your example is treated as a special character.
Apostrophes (single quotes) pass the string unchanged, i.e. $ \ ` is treated as a regular character in text.
It makes sense to replace quotes in send with apostrophes and "play" with it.
Linux is not at hand, so I can not accurately specify the working version of the line.
Unfortunately, I didn't find an answer.
Sorry.
And this doesn't work?
nc 216.146.43.71 80 | egrep '([0-9]{1,3}[\.]){3}[0-9]{1,3}'
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question