Output systemsetup in Mac to file

I am trying to output a command on Mac OS for current Time Zone to file. I am currently using

wait sudo systemsetup -gettimezone > /var/opt/BESClient/TimeZone.txt and trying to pull the line back in an Analysis. I get no return in the Analysis. The command runs with no error code. Unfortunately, this is on a remote device that I am not able to see.

Couple of questions for anyone who works with Mac’s.
Is this command correct?
Is /var/opt/BESClient a good place on Mac to output this file?

Thanks

Consider using the relevance local time zone directly in your analysis?

I probably should have mentioned that this was for DMZ relay association across the globe. While I looked at local time zone, it doesn’t clearly represent the chosen Time Zone.

I finally got it to work. In case anyone has a use for this:
// Remove Previous scripts
delete __createfile
delete “/tmp/TimeZone.sh”

// Use TimeZone.sh to output gettimezone to file and read back with Analysis
createfile until EOF
systemsetup -gettimezone > "/Library/Application Support/Bigfix/BES Agent/TimeZone.txt"
EOF

wait chmod 555 "{(client folder of current site as string) & “/__createfile”}"
move “{(client folder of current site as string) & “/__createfile”}” "/tmp/TimeZone.sh"
wait /bin/sh -c “trap ‘’ 15; /tmp/TimeZone.sh”

// Remove scripts
delete __createfile
delete “/tmp/TimeZone.sh”

// If we get here and this fails, the install didn’t succeed
continue if {exit code of action = 0}

I then pull it back with in an Analysis:
lines of file “/Library/Application Support/Bigfix/BES Agent/TimeZone.txt”

2 Likes