LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Expect package - quotes interrupt running of scripts (https://www.linuxquestions.org/questions/linux-software-2/expect-package-quotes-interrupt-running-of-scripts-4175603988/)

adept7771 04-17-2017 03:01 AM

Expect package - quotes interrupt running of scripts
 
Hello community! I have installed Expect package for my debian server and it's work perfectly but i faced with one problem. Single quotes in Expect sripts all time interrupts running of script.

My example:

Code:

#!/bin/bash
#!/bin/expect
expect << END
spawn aptitude install MDS
expect "Accept this solution?" {send "n\r"}
expect "Accept this solution?" {send "Y\r"}
expect "Do you want to*" {send "Y\r"}
expect "To continue, enter*" {send "Yes\r"}
expect "To continue, enter*" {send "Yes\r"}
expect "Enter metadata_manager database name (leave blank for default \\'metadata_manager\\')\:" {send "metadata_manager\r"}
expect "Enter metadata_manager database username*" {send "\r"}
expect "Enter password:" {send "123\r"}
expect "Confirm password:" {send "123\r"}
expect "Installation can take some minutes*" {send "\r"}
expect "Enter the current IP address:" {send "10.130.139.114\r"}
expect "Do you want to use current ip*" {send "Y\r"}
expect "Enter the metadata enhancer address:" {send "127.0.0.1\r"}
expect "Enter account_manager database name*" {send "\r"}
expect "Enter account_manager database username*" {send "\r"}
expect "Enter password:" {send "123\r"}
expect "Confirm password:" {send "123\r"}
expect "Installation can take some minutes*" {send "\r"}
expect "Username*" {send "\r"}
expect "Email address:" {send "\r"}
expect "Password*" {send "1q2w3eGSV\r"}
expect "Password*" {send "1q2w3eGSV\r"}
expect "Enter metadata_storage database name*" {send "\r"}
expect "Enter metadata_storage database username*" {send "\r"}
expect "Enter password:" {send "123\r"}
expect "Confirm password:" {send "123\r"}
expect "Installation can take some minutes*" {send "\r"}
interact;
END

Each time when expect see question:

Enter metadata_manager database name (leave blank for default 'metadata_manager'):

Expect interrupt install-script... i tryed to write:

- \'
- \\'
- *

But it doesnt matter to my situation... i alredy have broke my mind with it and srtongly ask for help...

bigrigdriver 04-18-2017 12:50 AM

I have looked at several examples of expect scripts.

My suggestion is to remove
#!/bin/bash from your script.

Bash is probably interpreting the single quote as an unmatched quote.

adept7771 04-18-2017 01:58 AM

Quote:

Originally Posted by bigrigdriver (Post 5698389)
I have looked at several examples of expect scripts.

My suggestion is to remove
#!/bin/bash from your script.

Bash is probably interpreting the single quote as an unmatched quote.

I made in header:
Quote:

#!/usr/bin/expect
and refactored code of script:
Code:

spawn aptitude install MDS;
expect "Accept this solution?" {send "n\r"};
expect "Accept this solution?" {send "Y\r"};
expect "Do you want to continue?" {send "Y\r"};
expect "To continue, enter \"Yes\"\; to abort, enter \"No\":" {send "Yes\r"};
expect "To continue, enter \"Yes\"\; to abort, enter \"No\"\:" {send "Yes\r"};
expect "Enter metadata_manager database name (leave blank for default 'metadata_manager'):" {send "test\r"};

But result is the same. Install script interrupting each time when it see question with quotes... also i tried

Code:

expect "Enter metadata_manager database name*" {send "test\r"};
But it didn't matter.

jefro 04-18-2017 03:32 PM

Might try the script with autoexpect to see if it can fix it. ??


All times are GMT -5. The time now is 01:56 PM.