I am attempting to automate installation of Alpine Linux in vm-bhyve under FreeBSD and expect dies shortly after the boot menu times out and launches the Alpine Linux installation.
#!/usr/bin/env expect
spawn vm install -f alpine alpine.iso # shortened for brevity
expect "localhost login:"
send "root\r"
...
This results in the following error:
"while executing
"send "root\r"
I suspect that whenever the screen clears and it starts to boot, that confuses expect to think the program is done? And, as a result, the script dies.
I've never coded expect in this manner before, is it possible to do it with expect?
I also tried setting a global timeout before spawning the vm install cmd which boots and immediately goes into the console for the guest, but that didn't change anything so I excluded it from the script above. Sleep in the same spot didn't help, it just delayed booting (and subsequent failure by the amount I set for sleep).
EDIT: I am trying to launch the installer in the background, sleep 30s, then attach a console. At this point, Expect should work.