I'm looking for some assistance with this TCL script. I'm working on developing a very basic script that will ask the user how many IP's they want to enter, then collect each of those IP's into a list so that they can be ping'd. I'm brand new to TCL scripting as of last week and I'm having two issues with the following script (I apologize ahead of time, as this script is probably pretty sloppy):
lappend iplist set y 0 puts "This script will ping each address that you specify." puts -nonewline "How many IP’s will you enter? : " flush stdout gets stdin numberof puts "" for {set x 0} {$x<$numberof} {incr x} { incr y puts -nonewline "IP Address " puts -nonewline $y puts -nonewline " : " flush stdout lappend iplist [gets stdin ?address?] } foreach item $iplist { {ping $item } }
The first issue is that my list is not being created the right way. The output will work correctly, but in testing I tried using just whole numbers to make sure the list was working. So, I entered "2" addresses. The loop works fine. However, entering IP addresses of 5 and 10, I noticed the list creates 1 and 2. Basically, the list appends to the end however many digits are in the stdin ?address?. This doesn't make any sense to me whatsoever.
The second issue is the last 'for' loop. I'm not sure how to actually ping each item in the list, as I get "invalid command name ping." Looking for help in getting that functionality to work as well if possible!