Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to get the next ip for given ip
ex: 10.10.10.1 -> 10.10.10.2
ex: 10.10.10.255 -> 10.10.11.0

Answer Posted / amarnath

#!/usr/local/bin/expect



set ip 10.20.245.250
set a [split $ip .]
puts $a
set oct1 [lindex $a 0]
set oct2 [lindex $a 1]
set oct3 [lindex $a 2]
set oct4 [lindex $a 3]

for {set i 0} {$i<=4574} {incr i } {
if {$oct4<=255} {
puts [join "$oct1 $oct2 $oct3 $oct4" "."]
incr oct4 }
if {$oct4==256} {
incr oct3
set oct4 0
puts [join "$oct1 $oct2 $oct3 $oct4" "."]
incr oct4 }
if {$oct3==256} {
incr oct2
set oct4 0
incr oct3
set oct3 0
puts [join "$oct1 $oct2 $oct3 $oct4" "."]
incr $oct4
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category