开发者

Pass data into a tool's stdin using NSTask

开发者 https://www.devze.com 2023-03-10 15:01 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号