Wonderful. Unfortunately, I know the way to go about doing this, I just don't know the exact syntax. Sed and Awk are somewhat of a mystery to me, but I'm sure you could more than easily figure it out.
1. Verify if eth0 or eth1 has been configurated.
Running ifconfig and then piping the output to sed/awk to parse the lines that come out for the "inet addr:XXX.XXX.XXX.XXX" section (located in the second line of the output).
2. Connection to eth0 or eth1 can get through.
Now, I'm not quite sure what you mean by this, but if you're on a network with access to the internet, pinging a website (or something of the like) will let you know if network traffic can get through.
If you're on an intranet with no contact with the outside world, then ping the router, or destination and see if the packets are received and acknowledged.
$ ping -c4 192.168.1.100
As an example.
3. Get its subnet IP address.
This step could be rolled into step one, as you may want to avoid the few extra flops it would take to re-run a particular process (ifconfig). The subnet IP address (the "broadcast" address), is also in the second line of the output, and is the next printed value.
Here's what my ifconfig output looks like for eth0:
eth0 Link encap:Ethernet HWaddr 00:40:f4:19:c5:f9
inet addr:192.168.2.12 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::240:f4ff:fe19:c5f9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15690 errors:0 dropped:0 overruns:0 frame:0
TX packets:14484 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:12045660 (11.4 MiB) TX bytes:286089 (2.1 MiB)
Interrupt:201 Base address:0x9800