tcl - Need assitance with expect script -


i trying achieve expect script have txt file..

it contains data like

1 ip telnetname slot1 slot2 assoc1 assoc2 mep1 mep2 2 ip telnetname slot1 slot2 assoc1 assoc2 mep1 mep2 

i want make expect script each line in file spawns telnet session variables set line spawn telnet line 1 each 1 of words variable set later used in commands.

this tried far

foreach ip $ips telnetname $telnetnames slot1 $slots1 slot2 $slots2  { commands here } 

it isn't quite clear you're trying description, easiest make code work this:

# slurp data tcl; it's not *that* long, it? set f [open "inputfile.txt"] set data [read $f] close $f  foreach line [split $data "\n"] {     # tcl's [scan] c's sscanf(), memory-safe!     if {[scan $line "%d %s %s %s %s" -> ip telnetname slot1 slot2] != 5} {         # not expected; skip it!         continue     }     # $ip, $telnetname, $slot1 , $slot2 ... } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -