Hi. Let me start by saying I googled for answers to both of these for about a half hour, to no avail. I found related topics; got close! But, alas, no cigar. As part of a small script I'm using the following to get the name of my network interface, "eth0", and tell it to another command.
iface=$(ifconfig -s | head -n 2 | tail -n 1 | head -c 8)
My cousin tested it for me on his machine (different distro), but the head-tail-head doesn't find the same field since the file contents aren't identical. Is there a way to retrieve the device name regardless of what distro you use?
Also, I'm retrieving my gateway's internal IP using:
nameserver=$(cat /etc/resolv.conf | tail -c14)
Obviously resolv.conf is different, even between Sabayon 4 & ubuntu intrepid (my last config; haven't tested it w/ Slack 12.2 yet). So in a similar vein, is there a way to retrieve the gateway's internal IP regardless of distro?
Thanks for your time.