Results 1 to 4 of 4

Thread: Expect: Script help please!

  1. #1
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Expect: Script help please!

    Hi All,
    I'm trying to learn to use the automation scripting tool Expect here I have a script named ExpectPass.
    On my computer I have a user account named j
    So From root I try runing ./ExpectPass j
    Code:
    #!/usr/bin/expect
    spawn passwd [lindex $argv 0]
    set password [lindex $argv 1]
    expect "password:"  
    send "$password\r"
    expect "password:"
    send "$password\r"
    expect eof
    From there, Im just not sure how to put in a password. The shell does prompt briefly, for a "Enter new Unix password:" but its not taking input as far as I can tell. If i type anything at this prompt I get:

    Code:
    # y7
    newpass: command not found
    If I dont type anything I end up back at the prompt.
    Can anyone explain what is going on here?
    This is an example from the book "Exploring Expect", Page 5
    Please help!
    ~Conradin~

  2. #2
    Join Date
    Jan 2009
    Location
    ::1
    Beans
    2,485

    Re: Expect: Script help please!

    you say "user account named j" which you give as argument 1, bu the script puts "$argv 1" into ... $password

    I would start by running 'passwd' just from the command line to see it's workings.
    And autoexpect is always a big help in developing expect scripts

  3. #3
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Re: Expect: Script help please!

    Yeah, I figured it out after looking at it again. The script runs fine when you pass it the arguments user-name & password.
    as in:
    Code:
    #./ExpectPass <user> <password>
    its set up to run as root too, since if I ran it as the user j, it would ask me to retype the current password before entering the new one.

    Any ways, Ive heard of autoexpect, but I haven't located a source for it. Where can I get autoexpect?
    ~Conradin~

  4. #4
    Join Date
    Nov 2008
    Location
    Maine
    Beans
    1,126
    Distro
    Ubuntu 10.04 Lucid Lynx

    Lightbulb Re: Expect: Script help please!

    ~Conradin~

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •