Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jdshub

macrumors newbie
Original poster
Jul 21, 2014
3
0
Hi,

basically I need to get a output of fdesetup status in order to check the variable and use it for a if check.

Basically I want to do the following:

Code:
## Check for FileVault 2 Status

fdesetup status
## Needs to get an output "deferred for user xxx"
## Exact output: FileVault is Off. Deferred enablement appears to be active for user 'xxx'.

if (fdesetup status = deferred) then
 #logout user
osascript -e 'tell application "loginwindow" to  «event aevtrlgo»'
exit 0
fi

Somehow I am stuck with this in my brain :/ sorry!

Best regards,
Dan :apple::apple:
 
Hi Dan,

You probably want something along the lines of:


Code:
if [ "`fdesetup status`" = "FileVault is Off." ]; then
	echo "Do stuff..."
fi

...I'm no shell scripting ninja so others may have better solutions.

Good luck!
 
Code:
EXIT STATUS
     The exit status of the tool is set to indicate whether any error was detected. The values returned are:

     0                  No error, or successful operation.

     1                  FileVault is Off.

     2                  FileVault appears to be On but Busy.

     11                 Authentication error.

     12                 Parameter error.

     13                 Unknown command error.

     14                 Bad command error.

     15                 Bad input error.

     16                 Legacy FileVault error.

     17                 Added users failed error.

     18                 Unexpected keychain found error.

     19                 Keychain error. This usually means the FileVaultMaster keychain could not be moved
                        or replaced.

     20                 Deferred configuration setup missing or error.

     21                 Enable failed (Keychain) error.

     22                 Enable failed (CoreStorage) error.

     23                 Enable failed (DiskManager) error.

     24                 Already enabled error.

     25                 Unable to remove user.

     26                 Unable to change recovery key.

     27                 Unable to remove recovery key.

     28                 FileVault is either off, busy, or the volume is locked.

     99                 Internal error.

It looks like you need to see if the exit code is 1.

From this post:
https://discussions.apple.com/message/20213829

Code:
set exitCode to do shell script "fdsetup status; echo $?"

Then you can just check against 1, or any other exit code. This feels more precise than parsing human-readable output.

-Lee
 
Hi Lee,

many thanks for your information.

My status code is:

Code:
XXX:~ dan$ fdesetup status
FileVault is Off.
Deferred enablement appears to be active for user 'dan'.
XXX:~ dan$ set exitCode to do shell script "fdsetup status; echo $?"
XXX:~ dan$ echo $?
0
XXX:~ dan$

I checked with another output code:

Code:
XXX:~ dan$ sudo fdesetup disable
Password:
Enter a password for '/', or the recovery key:
FileVault has been disabled.
XXX:~ dan
$ fdesetup status
FileVault is Off.
Decryption in progress: Percent completed = 99.25
XXX:~ dan$ set exitCode to do shell script "fdsetup status; echo $?"
XXX:~ dan$ echo $?
0

And another scenario:

Code:
XXX:~ dan $ fdesetup status
FileVault is On.
Encryption in progress: Percent completed = 0.19
XXX:~ dan $ set exitCode to do shell script "fdsetup status; echo $?"
XXX:~ dan $ echo $?
0

Do you have another clue?
That leads me to think, that we need to human readable output?

Best regards,
Dan
 
Last edited:
Hi Lee,

thanks a lot...I did it with a grep and checked it the output matches the grep.
Works like a charm :D

Best regards,
Dan
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.