So, lets have a FreBSD installation that got an IP address via DHCP using dhclient, and you want to know in a shell script the assigned default gateway for the specific interface.
You can use the following little script which prints the IP address of the default gateway to stdout.
#!/bin/sh
# read the default gateway from dhclient leases file for interface $1
DGW=`tail -r "/var/db/dhclient.leases.$1" | grep -m1 "router.*" | sed 's/;$//' | awk '{print \$3}'` > /dev/null
echo $DGW
Assuming you have the script in a file named getgw you can use it as follows to obtain the default gateway assigned to fxp0:
getgw fxp0