I am trying to pass an ip and port to my bash script from a list of devices but the script is reading it as multiple devices instead of port. So in the example from below it's trying to telnet to 4 devices as it's reading the ports as a device.
for device in `cat device-list.txt`;
do
hostname=$(echo $device | cut -d : -f 1)
port=$(echo $port | cut -d : -f 2)
./script.exp $device $username $password $port ;
done
I am trying to use cut to take the port and pass it through as a variable so my telnet should be e.g. abc.abc.com 30040 as one device and so on.
# Telnet
spawn telnet $hostname $port
This is my list of devices
abc.abc.com 30040
abc.abc.com 30041
I have tried searching this site already for answers.