Terminal OSX app open with arguments.

NSWorkspace launchApplicationAt

Just in case you’d like to try yourself to see if you get that working: that’s what i’ve tried quick&dirty…

[code]Dim oApp As FolderItem = GetFolderItem("/Applications/Utilities/Terminal.app", FolderItem.PathTypeNative)
Dim arguments As CFStringRef = “/bin/echo test”

Declare Function NSClassFromString Lib “Cocoa” (className As CFStringRef) As Ptr
Declare Function sharedWorkspace Lib “Cocoa” selector “sharedWorkspace” (class_id As Ptr) As Ptr
Declare Function launchApplicationAtURL Lib “Cocoa” selector “launchApplicationAtURL:options:configuration:error:” _
(obj_id As Ptr, aURL As Ptr, options As UInt32, configuration As Ptr, ByRef error As Ptr) As Ptr

Declare Function fileURLWithPath Lib “Foundation” selector “fileURLWithPath:” (ptrNSURLClass As Ptr, path As CFStringRef) As Ptr
Declare Function stringWithString Lib “Foundation” selector “stringWithString:” (ptrNSStringClass As Ptr, stringValue As CFStringRef) As Ptr
Declare Function dictionaryWithObjectForKey Lib “Cocoa” selector “dictionaryWithObject:forKey:” (class_id As Ptr, obj As Ptr, key As CFStringRef) As Ptr

Const NSWorkspaceLaunchAsync = &h10000
Const NSWorkspaceLaunchNewInstance = &h80000
Const NSWorkspaceLaunchConfigurationArguments = “NSWorkspaceLaunchConfigurationArguments”

Dim ptrNSWorkspaceClass As Ptr = NSClassFromString(“NSWorkspace”)
Dim ptrSharedWorkspace As Ptr = sharedWorkspace(ptrNSWorkspaceClass)

Dim ptrNSURLClass As Ptr = NSClassFromString(“NSURL”)
Dim ptrAppURL As Ptr = fileURLWithPath(ptrNSURLClass, oApp.NativePath)

Dim options As UInt32 = NSWorkspaceLaunchAsync + NSWorkspaceLaunchNewInstance

Dim ptrNSDictionaryClass As Ptr = NSClassFromString(“NSDictionary”)
Dim ptrNSStringClass As Ptr = NSClassFromString(“NSString”)
Dim ptrVal As Ptr = stringWithString(ptrNSStringClass, arguments)
Dim confRef As Ptr = dictionaryWithObjectForKey(ptrNSDictionaryClass, ptrVal, NSWorkspaceLaunchConfigurationArguments)

Dim errorRef As Ptr = Nil

Dim ptrRunAppRef As Ptr = launchApplicationAtURL(ptrSharedWorkspace, ptrAppURL, options, confRef, errorRef)[/code]

Personally I dont need this
Just didnt see it in the list of things you had tried already

Terminal is an odd duck
Basically you dont run commands in it as arguments to Terminal.app
Its why a lot of times you see opening terminal then using a script to tell terminal to run some unix command

Meanwhile I’ve created an example that works with macOS 10.14+.
It’s linked in this more generic topic.