What processes can be started using the executeTaskWithPathArgumentsTimeout function?

I use UIAutomation to automate the iPad application. I tried using (object) executeTaskWithPathArgumentsTimeout (path, arguments, timeout) to run Safari.app from my script:

var target = UIATarget.localTarget(); var host = target.host(); var result = host.performTaskWithPathArgumentsTimeout("/Applications/Safari.app", ["http://www.google.com"], 30); UIALogger.logDebug("exitCode: " + result.exitCode); UIALogger.logDebug("stdout: " + result.stdout); UIALogger.logDebug("stderr: " + result.stderr); 

I got the following results: exitCode: 5 standard output: STDERR:

Ive also tried to run an echo:

 var target = UIATarget.localTarget(); var host = target.host(); var result = host.performTaskWithPathArgumentsTimeout("/bin/echo", ["Hello World"], 5); UIALogger.logDebug("exitCode: " + result.exitCode); UIALogger.logDebug("stdout: " + result.stdout); UIALogger.logDebug("stderr: " + result.stderr); 

Results: exitCode: 0 stdout: Hello world STDERR:

So, it seems that performTaskWithPathArgumentsTimeout only works for specific applications.

Could you help me answer the following questions: 1. What does exitCode = 5 mean? 2. What processes can be started using the executeTaskWithPathArgumentsTimeout function?

+4
source share
1 answer

1) Output code 5 is most likely EIO, as defined in: I / O Error. You are trying to execute "/Applications/Safari.app", which is a directory, not a binary, to run a task.

2) You can start any application using the executeTaskWithPathArgumentsTimeout () function, which NSTask can run. If it is a valid executable, it should work.

However, for your specific example, Safari will not accept the argument passed on the command line as the URL to visit. Instead, you need to use open /Applications/Safari.app "http://www.google.com" :

 var result = host.performTaskWithPathArgumentsTimeout("/usr/bin/open", ["/Applications/Safari.app", "http://www.google.com"], 30); 
+4
source

Source: https://habr.com/ru/post/1383898/


All Articles