Need assist - ping to changing IP

I would like to make a script that would read an IP and then do to it ping.
That what I wrote:

#! /bin/sh
ip=$(/sbin/ifconfig lo | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}')
ping $ip

It worked on Ubuntu but wont work on OpenWrt.
I need the script to be like this cause I need to check several IP's

Thanks in advance for your help,

It does work but seems a bit pointless pinging localhost

# ifconfig lo
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:228 errors:0 dropped:0 overruns:0 frame:0
          TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:36488 (35.6 KiB)  TX bytes:36488 (35.6 KiB)

Try ifconfig on it own to see all interfaces

Not sure at all what you're trying to achieve. ifconfig will give you data about your own interfaces. It seems pretty pointless to ping your own interfaces.

That script should ping 127.0.0.1 -- if not, try sh -vx ./your-scritp.sh