Executing shell script with sudo that already has a sudo

I’m trying to do a server management for Valentina. They use a very simple shell script to start and stop the server. I don’t want to reinvent the wheel and thought I could just execute the script with AuthorizationMBS. However, the script already calls sudo. This here is the main part of the script:

sudo -S launchctl unload /Library/LaunchDaemons/com.paradigmasoft.vserver_x64.plist

This makes the Xojo code hang. Does anyone have an idea how I can still execute the script from within Xojo?

The code is rather simple:

[code]dim StartScript as FolderItem = ServerLocation.getFolderitem

if theAuthorisation = nil then
theAuthorisation = new AuthorizationMBS
theAuthorisation.KeepRights = true
if not theAuthorisation.SimpleNewAuthorization then
Return False
end if
end if

dim s(-1) as string
theAuthorisation.Execute(StartScript.UnixpathMBS, s, true)
if theAuthorisation.LastError = 0 then
dim theResult as Integer = theAuthorisation.Wait
Return True
else
Return False
end if[/code]

Xojo 2019r3.

You made it Synchronous, that’s why your app seems to hang.

Just make the shell Async (subclass it) then set the ExecuteMode to Shell.ExecuteModes.Asynchronous
Use the events to handle the responses and dataavailable for output handling and completed when it’s done.

AuthorizationMBS is not a shell so it doesn’t have modes. However, AuthorizationMBS has MakeStreamAsyncron which seems to do the same. I’ll try that out and if I can’t get it to work I’ll ask Christian.