title: how to create individual log files from different ip in the same txt
body: <p>I have already done an expect script. It works well. The script will read a txt file called ip_list. And then running command and output a log file. My question is if there are many different IP address in the txt file, how to modify my code to print out like one IP address for one log file?</p>
  
  <pre><code>set f [open "ip_list.txt"]
  set addr [split [read $f] "\n"]
  close $f
  
  foreach addr $addr {
  if {$addr eq {}} continue;
      set timeout 180
      match_max 1000000
      spawn telnet $addr
      expect {
      "*timed out*"   {puts "Host not responding"; continue}
      "'^]'."                                 {sleep .1}
      }
      expect "*login*"        {send "$user\r"}
      expect "*assword:*"     {send "$pass\r"}
      expect {
      "Login incorrect"   {puts "Bad Password or User"; exit}
      -re {[#&gt;] ?$}           {send "page-off\r"} 
      }
      log_file $customer\-License-$date.log
      expect -re {[#&gt;] ?$}
      send "show clock\r"
      sleep .5
      expect -re {[#&gt;] ?$}
      send "\r"
  puts "Connection closed, connecting to next one\r"
      sleep 1
      log_file
  expect eof;
  }
  </code></pre>
  
  <p>Any idea could help, thank you!</p>