I am trying to write a bash script using expect. This bash script will reside on a remote server, to be executed at a later date/time. I am using expect to read in a large data file, perform some processing on it, and writing out the bash script with appropriate values. To do I this, I set up variable that will hold the value of the bash script:
set awk_cmd "awk '\{print \\\$3\}'"if {$reboot==$reboot_N} {set command5 "echo '#!/bin/bash\n\ndeclare -i last_reboot=\$(w | grep up | grep days | ${awk_cmd})\n\nif (( \$last_reboot !< 8 )); then\necho \"Your ..."'> /root/script.sh
I have obviously redacted a good portion of the echo command. However, the error I'm getting is in the ${awk_cmd} portion. awk uses the format "awk '{print $3}'".
However, I cannot get the single quotes to print to the bash script. The above prints out {print $3} without the quotes, and all attempts at escaping the single quotes in the awk command have failed.
Notice that I am already using double quotes and single quotes in this. Everything in my command works EXCEPT the awk command.
What am I missing?
EDIT: To make it a bit simpler (I hope), I am trying to pass a literal single quote inside a single-quoted string