Last active
December 14, 2015 21:58
-
-
Save jtomschroeder/5154516 to your computer and use it in GitHub Desktop.
MacRuby: using NSTask to execute `ls -l -a` and print the result.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework "Cocoa" | |
task = NSTask.new | |
task.launchPath = "/bin/ls" | |
task.arguments = ["-l", "-a"] | |
stdoutPipe = NSPipe.pipe | |
task.standardOutput = stdoutPipe | |
task.launch | |
data = stdoutPipe.fileHandleForReading.readDataToEndOfFile | |
puts NSString.alloc.initWithData data, :encoding => NSASCIIStringEncoding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment