Escape-code "^[[43;1R" breaks my bash-expect script execution

114 Views Asked by At

I'm really young in linux and bash\expect scripting and i searched information for a days, but still don't have a solution.

This is my bash script with some expect blocks:

#!/bin/bash

expect <(cat <<'EOF'
set timeout -1
spawn $env(SHELL)
expect "#" {
send "(./(installation.sh) my_argument)\r"
}
expect {
    "*Accept this solution?*" {
        send -- "y\r"
        exp_continue
    }
    "*Do you want to continue?*" {
        send -- "y\r"
        exp_continue
    }
    "*Would you like to setup prompt server reservation using rsync?*" {
        sleep 1
        send -- "N;\r"
        exp_continue
    }
    "*Your choice*" {
        sleep 1
        send -- "\r"
        exp_continue
    }
    "*Enter a list of hosts which should be available to the database*" {
        sleep 1
        send -- "127.0.0.1;\r"
        exp_continue
    }
    "*Do you want to continue?*" {
        send -- "y\r"
        exp_continue
    }
    "#" {
    }
}
EOF
)

It spawns an another installation.sh script that installs some common packages and out propriatary soft.

It works well exсept one place: While installation.sh executing, terminal asks "YOUR CHOICE" that have a 3 variant of answer - 'del' to delete some host, 'add' to add new, ENTER to continue (see attached screenshots).enter pushing moment

I need give the ENTER pushing for doing nothing and continue script execution (i do it with send -- "\r"), but when terminal gives some output like "^[[43;1R" that break execution and stop script some minutes after that.

And when last literally 2 lines of executing before the end it stops.stop-moment

If anyone can help i will be very appreciate!

I tried to fix that with doing, but it doesn't help:

  1. replaced send -- "\r" with send -- "\n"
  2. changed file format with dos2unix to unix format to avoid DOS endings
0

There are 0 best solutions below