Hi, i'm making right now a little perl script to connect to my LCDd server to display on an 20X4 LCD screen. I need to get my Local, External, and VPN ip adress.
I have found a script for the WAN one that is OK, but when i use my script to get the internal one, it seem to put a \n at the end, because i have a change line, so my lcd see the variable as a 2 line input and don't display it, i need to make it not put the last line change code. here is my internal ip script:
Code:
#!/bin/bash
if [ -z "$1" ]; then
echo usage: $0 interface
exit
fi
IP=`/sbin/ifconfig $1 2> /dev/null|gawk '/inet addr/{print $2}'|gawk -F: '{print $2}'`
if [ "$IP" == "" ]; then
echo "none"
else
echo "$IP"
fi
this is working fine, if i send this: getip.sh eth0, i received this.
i set this as a variable, but in the variable i don't want the line change.
Code:
root@pbx:/usr/src $ getip.sh eth0
72.0.206.19
root@pbx:/usr/src $
this script is my external ip script:
Code:
#/bin/bash
curl -s hxxp://www(dot)whatismyip(dot)com/automation/n09230945(dot)asp
and the output of this one is like that:
Code:
root@pbx:/usr/src $ getextip.sh
72.0.206.19root@pbx:/usr/src $
and this is what i need, is there a way to have the same output from my first script?? thanx a lot!