Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Expect: How to get quotes to be sent

  • 05-03-2020 06:41PM
    #1
    Registered Users, Registered Users 2 Posts: 5,751 ✭✭✭


    In my below script i want to get the output from the spawn to be
    ovirt-aaa-jdbc-tool user password-reset user--password-valid-to="2025-09-15 10:30:00Z"
    
    but it ignores the quotes and gives me
    ovirt-aaa-jdbc-tool user password-reset user--password-valid-to=2025-09-15 10:30:00Z
    
    Ive tried several different ways, escaping the quotes etc but no joy. Code below


    #!/usr/bin/expect
    
    set password [lindex $argv 0]
    set username [lindex $argv 1]
    set valid_to "2025-09-15 10:30:00Z"
    set timeout -1
    
    
    spawn ovirt-aaa-jdbc-tool user password-reset $username --password-valid-to=$valid_to
    expect -re {(?n)^Password.*}
    send "$password\n"
    expect -re {(?n)^Reenter password.*}
    send "$password\n"
    expect -re {(?n)^user updated successfully.*}
    send "history > his && echo hi\n"
    expect -re {(?n)^#*}
    send "whoami\n"
    expect -re {(?n)^#*}
    expect eof
    
    Tagged:


Advertisement