0

I want to use Duplicity to backup my files from shell, but it requires the password to be passed twice before run. I thought of expect to solve the problem, but I cannot make it work. What I tried:

expect "Local and Remote metadata are synchronized, no sync needed.\nLast full backup date: none\nLast full backup is too old, forcing full backup\nGnuPG passphrase for decryption: " {send "$pass\r"}
expect "Retype passphrase for decryption to confirm: " {send "$pass\r"}

There is a multi line message from Duplicity. I tried expect -re to use regexp, but it did not recognize the r option. I use Alpine in a docker container.

jokey
  • 21
  • 6
  • [pure speculation] Usually those happens because busy box's commands are trimmed down [/pure speculation], which might be your issue here – β.εηοιτ.βε Nov 07 '22 at 11:11
  • 1
    It is unclear what you are asking: When you type `expect` here, is this the **expect**- command `expect`, or is it the **shell**-command expect? It would make more sense if you would post your whole expect script, and also that part of your shell script which runs the expect script. – user1934428 Nov 07 '22 at 11:25

1 Answers1

2

The first pattern is not matching because Expect uses \r\n for all newlines.

Run your code with expect -f script.exp for verbose output to see how expect is attempting to match.

You could write

expect "Local and Remote metadata*GnuPG passphrase for decryption: " {send "$pass\r"}

By default, the expect command uses glob-matching like the tcl string match commabnd

glenn jackman
  • 238,783
  • 38
  • 220
  • 352