expect u question - i'm stumped - completely... 
Author Message
 expect u question - i'm stumped - completely...

Ok,  I've tried this again and again, and I can NOT seem to get
this to work.  Before I show you the code, let me explain what i'm
trying to do....  I need to do an rexec on a remote host, simple, right?
So I thought, I wrote a simple function that took a hostname, and
accountname and a password, it then does (on an IBM rs6000) an rexec -n
to the hostname with the command (a simple file copy for now, until i get
this thing working).  I then expect for the name, and send the account
name, then i expect for the password, and send the password.  It goes
through all this, but then, it doesn't run the command!  Why?  I've
checked by running the rexec by hand, and I have the correct setup
there.  Any ideas?  Email responses preferred, but I read this group as
well.

Here is my function:

proc runRemex { filename hostname acctname passwd } {
    log_user 1

    spawn rexec -n $hostname cp $filename $filename.tst

    expect {
        {*ame*:}  {
            send "$acctname\r"
        } timeout {
            echo "Unable to connect to $hostname"
            close
            return
        }
    }

    expect {
        {*assword*:} {
            puts stdout "Sent $passwd"
            send "$passwd\r"
        } timeout {
            echo "Unable to connect to $hostname"
            close
            return
        }
    }

    wait
    return

Quote:
}

Thanks in advance for any help you can offer!

D

--
-----------.,------Coming-soon-to-a-PhD-Program-near-you-----.,--Carpe-Diem---
Ethernet is||Daniel Garcia - ATP Group - LLNL Gigabit Testbed||AntiClipperCens
for Sissies||  Lawrence Livermore Nat'l Labs - Livermore, CA ||orshipFightingF

 Try Linux ||    This .sig file (c)1994 by Daniel Garcia     ||saderForRights.

 Fibre Channel - Unix - TCP/IP - Music - MIDI - Biking - Networking - Reading



Mon, 03 Mar 1997 02:21:54 GMT  
 expect u question - i'm stumped - completely...


||Ok,  I've tried this again and again, and I can NOT seem to get
||this to work.  Before I show you the code, let me explain what i'm
||trying to do....  I need to do an rexec on a remote host, simple, right?
||So I thought, I wrote a simple function that took a hostname, and
||accountname and a password, it then does (on an IBM rs6000) an rexec -n
||to the hostname with the command (a simple file copy for now, until i get
||this thing working).  I then expect for the name, and send the account
||name, then i expect for the password, and send the password.  It goes
||through all this, but then, it doesn't run the command!  Why?  I've
||checked by running the rexec by hand, and I have the correct setup
||there.  Any ideas?  Email responses preferred, but I read this group as
||well.
||
||Here is my function:
||
||proc runRemex { filename hostname acctname passwd } {
||    log_user 1
||
||    spawn rexec -n $hostname cp $filename $filename.tst
||
||    expect {
||        {*ame*:}  {
||            send "$acctname\r"
||        } timeout {
||            echo "Unable to connect to $hostname"
||            close
||            return
||        }
||    }
||
||    expect {
||        {*assword*:} {
||            puts stdout "Sent $passwd"
||            send "$passwd\r"
||        } timeout {
||            echo "Unable to connect to $hostname"
||            close
||            return
||        }
||    }
||
||    wait
||    return
||}
||
||Thanks in advance for any help you can offer!
||
Hi I was recently stung by the use of * in the expect string,
once I removed that it all worked fine.  Don't ask me why.

So I would suggest you use actual prompts rather than the above, eg.

use say: {Password:} instead of {*assword*:}

Cheers, Naran.



Tue, 04 Mar 1997 21:44:53 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. proc global problem - I'm completely stumped

2. trivial Expect script has me stumped

3. Question about 'Expect'

4. Expect: Trouble 'expect'ing linefeeds

5. Newbie Expect Question: where does Expect store values returned from an expect command

6. An AWK poser that's stumped a novice

7. Okay, I'm stumped.

8. error 19 - i'm stumped - snip [1/1]

9. I'm Stumped ...

10. I'm stumped on threads

11. Problems installing pythonwin - I'm stumped

12. [Fwd: Re: I'm stumped on threads]

 

 
Powered by phpBB® Forum Software