[SGVLUG] RE: Got it! (was Automating (scripting) telnet)

Emerson, Tom Tom.Emerson at wbconsultant.com
Tue Feb 21 19:37:03 PST 2006


OK, some success (for mass-deletions at least)

> -----Original Message-----
> Behalf Of Emerson, Tom
> 
> In a nutshell, I think I want/need something like this:

I almost had it correct -- here is where I went wrong:

>    for {set i [lindex $argv 1]) ($i>0) () {
>       send "dele $i"
>       expect "+OK message $i deleted"
>       incr i -1
>    }

there were two or three things bad here:

  -- in the "for" command, I didn't notice that each segment should be surrounded by BRACES -- I was using PARENTHESIS [the font used by putty is pretty bad on differentiating these, and I see my e-mail client isn't much better -- then again, it could be *my* eyes... 8-) ]

  -- in the "lindex" command, I should have been using argument 0, not 1, of course, if I wanted to make this script more "secure", I would pass the user ID and password as script parameters, so this might actually be lindex 2 ;)

  -- the real text returned by the server is "+OK msg #n deleted"

but at least it beats typing "dele ..." 600+ times :)



More information about the SGVLUG mailing list