On Wed, Jul 31, 2002 at 02:37:16AM -0000, Joe Giles wrote: > Is there a preset variable in Linux that stores your IP address? > > I use DHCP, and I would like to use an IP variable (If one exists) to set my DISPLAY >option... Can anyone help ? > > Example > > display=$MYIP:0;export display > > There $MYIP would be the actual Linux variable to export...
#!/bin/sh # ## Extracts the current IP from ifconfig. # ## usage: MY_IP=`my_ip` (with back quotes) # ####################################################################### # #WAN_IFACE=ppp0 WAN_IFACE=eth0 #WAN Interface # make sure the interface is up to start with ... if ifconfig | grep $WAN_IFACE >/dev/null 2>&1 && ifconfig $WAN_IFACE |grep UP >/dev/null; then # extract just our desired IP ... ifconfig $WAN_IFACE | grep inet | cut -d : -f 2 | cut -d \ -f 1 exit $? fi exit 1 #--- eof my_ip In your case, you might add: else echo localhost =========== ... just in case. -- Hal Burgiss -- redhat-list mailing list Unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list