Big Sur Osascript

I used the following code to open the terminal app and connect to client via ssh, but on Big Sur this does not work anymore, terminal app opens but nothing more happens…

dim cmd as String
cmd="osascript -e 'tell application ""Terminal""' -e Activate -e 'do script ""ssh -o \""StrictHostKeyChecking no\"" " +user+"@"+ip+"""' -e 'end tell'"
ssh.Execute (cmd)

is there any chance to get this working again and still be compatible with OS X prior Big Sur?


Does your code work if you try from the Script Editor?
And if you try removing unnecessary statements, for testing?

(sorry, I don’t have Big Sur, so I can’t test)

My first question is why are you using AppleScript to perform a shell task?

If your application is NOT App Sandboxed, you can use the Xojo shell class. If your application is Sanboxed, you can get the NSTask class from the Ohanaware App Kit or the MBS plugin and use that (I’ll be honest I’ve not actually tried SSH from a Sandboxed application).

Do you have “Hardened Runtime” enabled when code signing your application, and the AppleScript entitlement along with the AppleScript Usage string? I have written a quick guide here Using AppleScript in your apps with App Wrapper 4

Lastly, when submitting apps to the  App Store, scripting “Terminal” is prohibited (for security) maybe they’ve rolled that “Security” out to the macBS?

Please check NSAppleScriptMBS class in MBS Xojo Plugins.
It allows you to compile and execute AppleScripts. Also can set/get properties in the script and check whether your app has automation permissions.

Put the script into the script editor, save it as compiled, and drag it into your app.

Did you allow your app to use the terminal in the security/privacy of system settings? I am using this code to open terminal in Big Sur:

Var s As New shell
s.Execute("osascript -e 'tell application ""Terminal""' -e Activate -e 'do script ""ssh " + SSHUserField.Text + "@" + SSHServerField.Text + """' -e 'end tell'")

Thanks to all!
for some reason it works now, i did some changes in security/privacy settings.

@Sam_Rowlands : I need to use the terminal because I do some more tasks like editing files with pico and some more, that’s why I need to use terminal and not just a xojo shell class.