OK--II think I've figured it out.
set command5 "echo '#!/bin/bash\n\ndeclare -i last_reboot=\$(w | grep up | grep days | awk '\\\''\{print \$3\}'\\\'')\n\nif....." > script.sh
The above produces the following:
#!/bin/bash
declare -i last_reboot=$(w | grep up | grep days | awk '{print $3}')
if (( $last_reboot >= 7 )); then
echo "Your ..."
#!/bin/bash
declare -i last_reboot=$(w | grep up | grep days | awk '{print $3}')
if (( $last_reboot >= 7 )); then
echo "Your ..."
I found the answer at this link: https://www.linuxquestions.org/questions/linux-newbie-8/problem-escaping-single-quote-when-using-usr-bin-expect-c-4175600628/here:
. I just had not figured out the correct escape sequence.