I am trying to automatically unlock db using follow command:
fdbcli --exec "unlock e37047b3d0c2860b235d684a5a29baac"
the output is like
Unlocking the database is a potentially dangerous operation.
Repeat the following passphrase if you would like to proceed (3USlDAq5EF) :
we need to capture the passphrase and input it back, how to do that?
I tried to use go expect, but it sounds it only capture the first line of the output, meaning couldn’t get the passphrase. I also attach a simple go code:
package main
import (
"fmt"
gexpect "github.com/ThomasRooney/gexpect"
)
func main() {
child, err := gexpect.Spawn("fdbcli --exec \"unlock e37047b3d0c2860b235d684a5a29baac\"")
if err != nil {
panic(err)
}
_, receiver := child.AsyncInteractChannels()
line1, open := <-receiver
fmt.Println(line1)
fmt.Println(open)
child.Expect("):")
child.SendLine("passphase")
child.Interact()
child.Close()
}
the output is:
Unlocking the database is a potentially dangerous operation.
true
kindly share any advise how to capture passphase. thanks.