#!/usr/bin/env expect
# open first argument to program...
set fd [open [lindex $argv 0]]
# for each line using that file handle...
while {[gets $fd line] >= 0} {
# split on , and select the last one...
set lastcolumn [lindex [split $line ","] end]
# whoops there's some whitespace so clear that...
set ip [string trim $lastcolumn " "]
puts ">$ip<"
}