instead of whoising the nickname, you may just make a /who nickname
this command will return in the raw 352 the realname.
here's an example:
23:44:13 -> irc.voila.fr WHO nickname
23:44:13 <- :irc.voila.fr 352 TropNul * theident thehost hisnetwork nickname H :0 THEREALNAME
23:44:13 <- :irc.voila.fr 315 TropNul nickname :End of /WHO list.