| |||||||||||
tcl string works Posted by xramm (xramm), 8 February 2008 I am using expect , and want to add +1 to an IP number which is being read from file. In unix shell script I did it by using cut command , I wonder it is possible to do in Tcl IP number format like 192.168.xxx.yy and want to make form as 192.168.xxx.yy+1 any advise ? Posted by admin (Graham Ellis), 9 February 2008 I would split the incoming IP address up with regexp, add one to the last number with expr, and rebuild.Posted by xramm (xramm), 9 February 2008 thanks for your advisewhich regexp option (switches) will be suitable for accomplish this task ? -line ? Posted by admin (Graham Ellis), 10 February 2008 I don't think you'll need any options at all!Posted by xramm (xramm), 10 February 2008 as an sample; my ip address is 172.26.234.13 and want to make it 172.26.234.14ip1="172.26.234.13" would you please give me an example to start ? Posted by admin (Graham Ellis), 10 February 2008 If you have a look at the other threads on this board, you'll find that we're here to help with learning rather than to provide a free "write it for me" service ... so I am rather reluctant to do the whole job for you. HoweverCode:
gave this result Code:
Posted by xramm (xramm), 11 February 2008 we're here to help with learning rather than to provide a free "write it for me" service ... ->> of course , I am aware of this, I do not want you have wrong ideas about me. I asked because I am very new to Tcl, I am familiar with unix shell programming, I am able to write code in unix shell easily like my question but Tcl totally different and I cannot find adequate information yet. Thanks for your help. Posted by xramm (xramm), 11 February 2008 ... we're here to help with learning rather than to provide a free "write it for me" service ... ->> of course , I am aware of this, I do not want you have wrong ideas about me. I asked because I am very new to Tcl, I am familiar with unix shell programming, I am able to write code in unix shell easily like my question but Tcl totally different and I cannot find adequate information yet. Thanks for your help. Posted by xramm (xramm), 11 February 2008 ... we're here to help with learning rather than to provide a free "write it for me" service ... ->> of course , I am aware of this, I do not want you have wrong ideas about me. I asked because I am very new to Tcl, I am familiar with unix shell programming, I am able to write code in unix shell easily like my question but Tcl totally different and I cannot find adequate information yet. Thanks for your help. Posted by xramm (xramm), 11 February 2008 <#>... we're here to help with learning rather than to provide a free "write it for me" service ...</#>->> of course , I am aware of this, I do not want you have wrong ideas about me. I appreciate this policy.. I asked because I am very new to Tcl, I am familiar with unix shell programming, I am able to write code in unix shell easily like my question but Tcl totally different and I cannot find adequate information yet. Thanks for your help. Posted by xramm (xramm), 11 February 2008 I could not make regexp worked for split IPs up. My solution is: #split IP address up set ilk [ lindex [ split $site '\.' ] 0 ] set iki [ lindex [ split $site '\.' ] 1 ] set uc [ lindex [ split $site '\.' ] 2 ] set son [ lindex [ split $site '\.' ] 3 ] incr son #setup for host set ip3 "$ilk.$iki.$uc.$son" Posted by admin (Graham Ellis), 11 February 2008 Yes, that works .... although I do find myself thinking if I see code repeated "surely there's an easier way".Yes, I understand completely that you're new to Tcl and indeed we provide this board to help. But where the question starts moving towards complete chunks of code, there are better / easier way such as books and courses which provide a far more effective route than a forum. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |