Skip to content

Instantly share code, notes, and snippets.

@jtomschroeder
Last active December 14, 2015 21:58
Show Gist options
  • Save jtomschroeder/5154516 to your computer and use it in GitHub Desktop.
Save jtomschroeder/5154516 to your computer and use it in GitHub Desktop.
MacRuby: using NSTask to execute `ls -l -a` and print the result.
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