How would I use dscl
in Objective-C and obtain its output? The command I want to pass as if it is in Terminal is:
dscl . -readall /Users UniqueID | awk '/^RecordName:/ {name=$2}; /^UniqueID: / {if ($2 > 500) print name}'
I know how to launch system_profiler with arguments such as -xml, etc. but I can't figure out how to pass such a long string in where is actually works.
I know system_profiler is /usr/sbin/system_profiler, but what about dscl?
Your best bet is to launch that as if it were a shell script. Either stick it in your project as a shell script in a file or use
NSTask
to compose a command line that invokes /bin/sh, passing the command as a string to allowsh
to parse it.I.e.
/bin/sh -c ".... your command string ...."