GOAL:
Pull the IP address from the server. However, the issue comes into play that dedicated and VPS are very different. What is the best or most ideal way to pull and do a check and print the IP Address?
I guess I could do a check with the following?
root@host]# /sbin/ifconfig venet0:0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
IP IS HERE
root@host]# /sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
eth0: error fetching interface information: Device not found
To get the IP address of your server whether it be a VPS or not you can do the following:
Hope this helps.
Hat tip to jwpat7 for providing the awk command that is more succinct than the grep, cut, awk.