Cant you solve this using the $gettok command?