Get return value of execute command

Hello,

I try to get the return value of the execute command line command.

var response = executeCommandLine("sudo","reboot") 
loginfo("w", response.toString)

to check if everything is fine. But error is “‘toString’ is not a member of ‘Object’”

Regards

variable response should already be a string. I’ve never seen string.toString cause an error though; are you sure that is the offending line?

It is the line yes…I am on oh3.1 M5 build

If it really is an object, you should get a better view with
loginfo("w", "my response {}", response)

You have to supply a java.time.Duration as the first argument to tell executeCommandLine the maximum amount of time to wait before timing out. Without that executeCommandLine returns immediately before the called script returns.