I'm quite new to bash. I'm trying to achieve a quite easy thing but it looks like extremely complicated...

I'm trying to read variables from a file (ip address, username, password) and connect to firewalls to change them.

The file is around 100 lines and I'm trying to read one by one, chose the IP address of the firewall from the 2nd column, first username and pass from the 3rd and 4th column, second username and pass from the 5th and the 6th column.
The file looks like:

```
Office1    IP   uname1 pass1       uname2  pass2
Office2    IP   uname1 pass1       uname2  pass2

```

All the raws are separated by tabs
The script looks like this one:

```
   #!/bin/bash
   office=`awk '{print $1}' TEST.txt`
   user1=`awk '{print $3}' TEST.txt`
   user2=`awk '{print $5}' TEST.txt`
   password1=`awk '{print $4}' TEST.txt`
   password2=`awk '{print $6}' TEST.txt`
   /usr/bin/expect <<EOF 
   for p in `cat TEST.txt | awk '{print $2}'`
   do
   # echo $user1 ", " $password1", " $user2", "$password2"
   set timeout 20
   spawn telnet $p
   expect "login:"
   send "cipollone"
   send \r
   expect "password:"
   send "mypass"
   send \r
   expect ">"
   send "set admin user $user1 password $password1 privilege all"
   send \r
   expect ">"
   send "set admin user $user2 password $password2 privilege all"
   send \r
   expect ">"
   send "save"
   send \r
   expect ">"
   send "exit"
   send \r
   send \r
   send \r
   # echo $office $p "DONE"
   # echo \r
   # echo $office $p "DONE" >>  results.txt 
   # echo \r >> results.txt
   exit
   EOF
   done < TEST.txt

```