1
Objective-C에서 dscl
을 어떻게 사용하고 출력을 얻을 수 있습니까? 내가 터미널에있는 것처럼 전달하려는 명령은 다음과 같습니다Objective-C에서 dscutil 실행
dscl . -readall /Users UniqueID | awk '/^RecordName:/ {name=$2}; /^UniqueID:/{if ($2 > 500) print name}'
가 나는 등 -xml, 같은 인수 system_profiler를 시작하지만, 나는 그런 긴 문자열을 전달하는 방법을 알아낼 수있는 방법을 알고 실제로 작동하는 곳입니다.
필자는 system_profiler가/usr/sbin/system_profiler라는 것을 알고 있지만 dscl은 무엇입니까?
시도 : outFileData = [taskLauncher launchTask : @ "usr/sh"withArguments : [NSArray arrayWithObjects : @ "-c", @ "dscl.-readall/Users UniqueID | awk '/^RecordName :/{name = $ 2};/^ UniqueID :/{if ($ 2> 500) 인쇄 이름} ' ", nil]]; – John
'usr/sh'을 작동하지 않았습니까? 그건 옳지 않아. – bbum
시도 : outFileData = [taskLauncher launchTask : @ "bin/sh"withArguments : [NSArray arrayWithObjects : @ "- c", @ "dscl. -readall/Users UniqueID | awk '/^RecordName :/{name = $ 2};/^ UniqueID :/{if ($ 2> 500) 인쇄 이름} ' ", nil]]; 그것은 작동하지 않았다. 또한/user/bin/sh를 시도했습니다 – John