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

Michael Proctor-Smith mproctor13 at gmail.com
Tue Feb 21 19:51:32 PST 2006


On 2/21/06, Emerson, Tom <Tom.Emerson at wbconsultant.com> wrote:
> 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 ;)

You can have expect prompt the user which is even better then passing
the username/password, as it will not end up in your history file, I
would tell you how but I do not have an ssh client where I am and can
not access my expect scripts to see how I did that.

>   -- the real text returned by the server is "+OK msg #n deleted"
>
> but at least it beats typing "dele ..." 600+ times :)
>
>
Anything beats that.


More information about the SGVLUG mailing list