I am trying to echo an expect script into a file so I can execute it on the fly.
Here is what I have so far:
#!/bin/bash
echo '#!/usr/bin/expect -f' > expect_file
echo 'expect "\[RETURN\]" {send "\r"}' >> expect_file
that will yield me a file with the following:
#!/usr/bin/expect -f
"}pect "\[RETURN\]" {send "
If I try and use echo and escape the quotations:
#!/bin/bash
echo '#!/usr/bin/expect -f' > expect_file
echo "expect \"\[RETURN\]\" {send \"\r\"}" >> expect_file
cat expect_file
exit 0
The expect command and parts of the line do not get echoed
#!/usr/bin/expect -f
"}pect "\[RETURN\]" {send "
How can I echo or place the follow lines of code into a file by itself from within my bash script?
#!/usr/bin/expect -f
expect "\[RETURN\]" {send "\r"}
expect ":" {send "q"}
expect "otherwise:" {send "y\r"}
expect eof {exit}