title: expect for ssh passwordless
body: <p>i have a file that has ip addresses, locations of files and passwords. I cannot use ssh key authentification, that's why i'm limited to use expect inside a bash script. the file contain the information as follow, seperated by spaces:</p>
  
  <p>ip location password</p>
  
  <p>ip location password </p>
  
  <p>etc</p>
  
  <p>my script is :</p>
  
  <pre><code> VAR=$(expect -c "
          set fid [open "file.conf" w]
          set content [read $fid]
          close $fid
          set records [split $content "\n"]
          foreach rec $records {
          set fields [split $rec]
          lassign $fields\ ip location password
          puts "$ip"
          puts "$location"
          puts "$password"}
          spawn ssh $ip tail -f $location &gt; /home/log_$ip 2&gt;/dev/null &amp;
          expect {
                  ".*Are.*.*yes.*no.*" { send "yes\n" }
                  "*?assword:*" { send "$password\r" }
             }
      ")
  </code></pre>
  
  <p>echo "$VAR"</p>
  
  <p>when i run the script, it gives me this error :</p>
  
  <p>wrong # args: should be "read channelId ?numChars?" or "read ?-nonewline? channelId"
      while executing
  "read "
      invoked from within
  "set content [read ]"</p>