Hi all,
I've got the bones of an AppleScript that pulls in info to update the Outlook ME Contact
Below I have what's working and what's not as far as dscl queries. I tried all different kinds of dscl commands I've found on the forum but these are not returning values even though when I use the dscl tool in interactive mode, the info is there. Any help would be awesome!
-- working
set loggedInUser to do shell script "/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'"
set emailAddress to do shell script "dscl . -read /Users/" & loggedInUser & " EMailAddress | awk 'BEGIN {FS=": "} {print $2}'"
set firstName to do shell script "dscl . -read /Users/" & loggedInUser & "| grep FirstName | awk '{print $2}'"
set LastName to do shell script "dscl . -read /Users/" & loggedInUser & "| grep LastName | awk '{print $2}'"
set phonenumber to do shell script "dscl . -read /Users/" & loggedInUser & "| grep PhoneNumber | awk '{print $2}'"
set Country to do shell script "dscl . -read /Users/" & loggedInUser & "| grep Country | awk '{print $2}'"
set Zip to do shell script "dscl . -read /Users/" & loggedInUser & "| grep PostalCode | awk '{print $2}'"
set State to do shell script "dscl . -read /Users/" & loggedInUser & "| grep State | awk '{print $2}'"
set City to do shell script "dscl . -read /Users/" & loggedInUser & "| grep City | awk '{print $2}'"
-- not working
set jobtitle to do shell script "dscl . -read /Users/" & loggedInUser & "| grep JobTitle: | cut -c 11-"
set streetaddress to do shell script "dscl . -read /Users/" & loggedInUser & "| grep Street | awk '{print $2}'"
set officeaddress to do shell script "dscl . -read /Users/" & loggedInUser & "dsAttrTypeNative:physicalDeliveryOfficeName | head -2 | tail -1 | cut -c2-"
I think there are two things at play.
1.) Job Title & Street Address have spaces in them and when I do a DSCL query, it appears on a "second" line.
2.) officeaddress - dsAttrTypeNative:physicalDeliveryOfficeName shows correctly in the Directory Editor but I can't grep it when I run DSCL from the command line. I found this link that explains a good regex but that's not working for me:
