I wrote the following expect script:
#!/usr/bin/expect -fset timeout 10spawn zypper in --no-recommends pdnsexpect { -re {^.* Solution (\d): (?:break pdns)} { set solution "$expect_out(1,string)" exp_continue }"Choose from above solutions by number or cancel" { puts "$solution" send "\r" }}
The program puts my $solution
correctly (in the example below, "3" is correctly placed), however then aborts execution, seemingly sending the carriage return, but not in a way that would make the zypper command I am spawning continue:
suse-test-647578bd8-95qsc:/ # ./install-pdns.expect spawn zypper in --no-recommends pdnsRefreshing service 'container-suseconnect-zypp'.Problem retrieving the repository index file for service 'container-suseconnect-zypp':[container-suseconnect-zypp|file:/usr/lib/zypp/plugins/services/container-suseconnect-zypp] Warning: Skipping service 'container-suseconnect-zypp' because of the above error.Loading repository data...Reading installed packages...Resolving package dependencies...Problem: the to be installed pdns-4.6.2-lp154.186.32.x86_64 requires 'systemd', but this requirement cannot be provided not installable providers: systemd-249.11-150400.6.8.x86_64[SLE_BCI] Solution 1: Following actions will be done: remove lock to allow installation of systemd-249.11-150400.6.8.x86_64[SLE_BCI] remove lock to allow installation of systemd-default-settings-branding-SLE-0.7-3.2.1.noarch[SLE_BCI] remove lock to allow installation of systemd-presets-branding-SLE-15.1-20.8.1.noarch[SLE_BCI] remove lock to allow installation of systemd-default-settings-0.7-3.2.1.noarch[SLE_BCI] remove lock to allow installation of systemd-presets-common-SUSE-15-150100.8.12.1.noarch[SLE_BCI] Solution 2: do not install pdns-4.6.2-lp154.186.32.x86_64 Solution 3: break pdns-4.6.2-lp154.186.32.x86_64 by ignoring some of its dependenciesChoose from above solutions by number or cancel [1/2/3/c/d/?] (c): 3suse-test-647578bd8-95qsc:/ #
I attempted combining the separate puts
and send
to puts "$solution\r"
, but it would abort without putting the value.
I attempted to add
eof { exp_continue }"Installing:" { exp_continue }eof {}
to the expect
block, and additionally tried to expect eof
outside of the existing expect
block. Neither seem to make the zypper
command continue.
To clarify: on a manual execution, zypper
expects "3" and then "enter" and then proceeds to install the package (hence the attempt with expecting "Installing:" afterwards).
I would appreciate any suggestions on what else to try!
Thanks for reading!