expect telnet issue
Vu Pham
vu at sivell.com
Mon Oct 15 12:27:36 PDT 2007
On Mon, 2007-10-15 at 12:08 -0700, Lonni J Friedman wrote:
> On 10/15/07, Vu Pham <vu at sivell.com> wrote:
> > On Mon, 2007-10-15 at 11:31 -0700, Lonni J Friedman wrote:
> > > Greetings folks,
> > > I've got a few expect scripts that I'm trying to use to automate
> > > telnet logins on some remote power switches. The expect scripts work
> > > perfectly on their own, but I want/need to create a wrapper for them
> > > so that they're all unified through a single script. When I call the
> > > expect script via a wrapper bash script, it no longer works. I get as
> > > far as the "spawn telnet foo.com" command, and then it just stalls
> > > without ever sending the username/password jazz.
> > >
> > > I'm guessing that some kind of env variable isn't getting passed
> > > somewhere, but I can't figure out what.
> > >
> > > Anyone have any ideas on what might be going wrong?
> >
> > Lonnie,
> >
> > Below is my test script ( I use it for my real ftp, but just tried with
> > telnet and it seems working )
> >
> > #!/usr/bin/expect
> > system "date"
> > spawn telnet 192.168.249.214
> > set timeout 600
> > expect {
> > timeout { puts "timed out when spawning telnet"; exit }
> > "connection refused" exit
> > "ogin:"
> > }
> > send "vu\r"
> > expect "ssword:"
> > send "mypassword\r\r"
> > expect "~]$"
> > ## script ends
> >
> >
> > Here is the output when I ran it.
> >
> > vu at coh2:~/telework/sh-scripts> ./a.sh
> > Mon Oct 15 14:11:15 CDT 2007
> > spawn telnet 192.168.249.214
> > Trying 192.168.249.214...
> > Connected to 192.168.249.214.
> > Escape character is '^]'.
> > Fedora release 7 (Moonshine)
> > Kernel 2.6.21-1.3194.fc7 on an i686
> > login: vu
> > Password:
> > Last login: Mon Oct 15 13:50:32 from 192.168.249.28
> > [vu at o ~]$
> >
>
> Thanks Vu. What is in your a.sh ?
>
> When I have just the following, I still get a hang at the telnet
> Username prompt:
>
> #!/bin/bash
> ./cuda-power0.exp
>
a.sh has the script at the beginning of my email.
Do you mean that cuda-power0.exp runs fine if you run it manually, and
do not run under thar wrapper ?
Vu
More information about the Linux-users
mailing list