Write a program to increment IP address to +10 and verify it is correct ip or not ??
example my ip is 172.122.132.143 increment this ip to +10 and verify it is valid ip or not
Answer / thiru
set ip "10.255.255.255"
set list [split $ip "."]
set oct1 [lindex $list 0]
set oct2 [lindex $list 1]
set oct3 [lindex $list 2]
set oct4 [lindex $list 3]
if {$oct4>254} {
set oct4 0
set oct3 [expr $oct3+10]
if {$oct3>255} {
set oct3 0
set oct3 [expr $oct3+10]
if {$oct2>255} {
set oct2 0
set oct3 [expr $oct1+10] }
if {$oct1>255} {
set oct1 0
}}} else {
set oct4 [expr $oct4+10]
}
puts "$oct1.$oct2.$oct3.$oct4"
| Is This Answer Correct ? | 0 Yes | 0 No |
How to run a package in tcl
Hi all, Is there any certification exams available for TCL and Perl. If so please let me know, my mailid is vpbharathi@gmail.com. Thanks in advance, Bharathi.P
How do you find the length of a string without using string length command in TCL??
how to increment eacl element in a list ? eg: incrlist {1 2 3} =>2 3 4
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
How to Swap 30 & 40 in IP address 192.30.40.1 using TCL script?
Where can find the sample tcl programs?
How TCL works
write a program to the given ip is valid private address or not(192.168.1.1)?
Test case on windows calculator?
Problems with utf-8 between Mac and PC
What does Tcl stand for?