I want to execute a command after my app opens the system terminal app. I open the terminal app with the following:
let url = NSURL(fileURLWithPath: "/System/Applications/Utilities/Terminal.app", isDirectory: true) as URL
let configuration = NSWorkspace.OpenConfiguration()
NSWorkspace.shared.openApplication(at: url, configuration: configuration, completionHandler: { app, error in
//app.executeMyCommand("echo hello")
})
And after it opened I want to execute the command "echo hello", as shown in the completionHandler. How can achieve this?

