Issue with Spawn

lehmafa
New Contributor

Hi Guys,

I do want to automate the creation of recovery keys on our mac environment and I do have some troubles with the expect of the spawn command. Details:

I need to expect the following string:

Enter a password for '/':

But I always end up getting the following information from the expect when running bash -x:

Enter a password for /:

My Code is:

expect -c " 
spawn `sudo fdesetup changerecovery -personal`
expect `Enter a password for ''''/'''':` {send $REC_PW
} 
sleep 1 exit
"

Any idea on what is going wrong here?

2 REPLIES 2

davidacland
Honored Contributor II
Honored Contributor II

I would probably use something like:

#!/usr/bin/expect

spawn sudo fdesetup changerecovery -personal
expect "Enter a password for ''''/'''':" 
send "$REC_PW
"
interact

Where is the $REC_PW variable value coming from?

That all being said, I think you're supposed to enable it with a plist file ([https://derflounder.wordpress.com/2015/02/02/managing-yosemites-filevault-2-with-fdesetup/])(https://derflounder.wordpress.com/2015/02/02/managing-yosemites-filevault-2-with-fdesetup/)

gachowski
Valued Contributor II

@lehmafa

This might help, not exactly what you asked : )

https://github.com/homebysix/misc/tree/master/2015-01-27%20MacBrained%20Reissuing%20FileVault%20Keys