title: Two commands or command pipe command - Spawn Expect
body: <p>I'm trying to execute a expect script into bash script, but when I try to execute the shell without "<code>| tee -a xxx.log</code>" (where xxx.log is a file than I want to write to record the ssh session).</p>
  
  <p>This code works fine:</p>
  
  <pre><code>comlog="ssh $USR@192.168.228.20"
  expect -c"
      spawn \"$comlog\"
      expect \"Password:\"
      send \"$PASS\r\"
      interact
  "
  </code></pre>
  
  <p>But when I try to add the "tee -a" command to save the ssh session the issue is </p>
  
  <pre><code>invalid command name "ssh"
  while executing
  </code></pre>
  
  <p>This is the complete command where I obtain the error message</p>
  
  <pre><code> comlog="ssh $USR@192.168.228.20 | tee -a /home/xxx.log"
   expect -c"
      spawn \"$comlog\"
      expect \"Password:\"
      send \"$PASS\r\" #Already Obteined
      interact
   "
  </code></pre>
  
  <p>I tried to change the "comlog" var as this ways but doesn't work :(</p>
  
  <pre><code> cssh $USR@192.168.228.20 \| tee -a /home/xxx.log
  </code></pre>
  
  <p>Does anyone know another way to save the ssh session started from expect? Or how can I send those two commands in same spawn command.</p>