Determining currently used NIC on CLI
I would think your problem is determining "service order." The basic magic you see happen in the System Preferences > Network where the highest ranking connected service sorts to the top.

This Mac OS Hints article discusses a similar problem and solution.