Pass data into a tool's stdin using NSTask
Let's say I h开发者_运维技巧ave some tool that, at some point in its execution, asks for user input. For example, it might ask for name and address. At another point it might ask for a password (and retyping of the password).
Is it possible for NSTask and NSPipe objects to deal with these things, i.e. to interact with command line tools?
See the setStandardInput:
method of NSTask. It allows you to set either a NSPipe or NSFileHandle as the task's standard input before launching it. There are also similar methods for standard output and standard error.
精彩评论