title: how to escape unusual/uniq characters from expect scripts?
body: <p>in expect script I can set any command or character to run it on remote machine
  but the sad thing is that expect cant send the same character as they defined in the expect script</p>
  
  <p>for example</p>
  
  <p>I want to run this line from expect script in order to change IP address from <strong>10.10.10.10</strong>
  to <strong>1.1.1.1</strong></p>
  
  <pre><code>    expect #  {send "perl -i -pe 's/\Q10.10.10.10\E/1.1.1.1/' /etc/hosts\r"}
  </code></pre>
  
  <p>but when I run the expect screen actually I see this line runing on the console:</p>
  
  <pre><code>   [root@localhost ~]# perl -i -pe 's/Q10.10.10.10E/1.1.1.1/' /etc/hosts
  </code></pre>
  
  <p>pay attention that the backslash before Q and before E was Disappeared</p>
  
  <p>so I wonder hoW to escape those characters from expect script?</p>
  
  <p>so expect will run the same line on the console as following</p>
  
  <pre><code>   [root@localhost ~]# perl -i -pe 's/\Q10.10.10.10\E/1.1.1.1/' /etc/hosts
  </code></pre>
  
  <ul>
  <li>REMARK set a backslash "\" before backslash doesn’t help!!! </li>
  </ul>
  
  <p>my script:</p>
  
  <pre><code> #!/bin/ksh
  
   #
    expect=`cat &lt;&lt; EOF
    set timeout -1
    spawn  ssh  192.9.200.10 
     expect {
               ")?"   { send "yes\r"  ; exp_continue  }
  
               word:  {send secret1\r}
            }
     expect #  {send "perl -i -pe 's/\\Q10.10.10.10\\E/1.1.1.1/' /etc/hosts\r"}
     expect #    {send exit\r}
     expect eof
     EOF`
  
  
      expect -c  "$expect" 
  </code></pre>
  
  <p>RESULTS ( after I run my script: )</p>
  
  <pre><code>  spawn ssh 192.9.200.10 
    root@'192.9.200.10 s password: 
    Last login: Sun Aug  4 22:46:53 2013 from 192.9.200.10 
    [root@localhost ~]# perl -i -pe 's/Q10.10.10.10E/1.1.1.1/' /etc/hosts
        [root@localhost ~]# exit
        logout
  
        Connection to 192.9.200.10  closed.
  </code></pre>