0

I have an application built in C# .dotnet 6 on macos.

I want the application to be able to seamlessly update itself.

It's downloads the latest pkg and my problem is how I run it.

I want to start this process using "sudo installer -pkg /tmp/mypackage.pkg -target /" but sudo ask for password on the standard input.

How can I start a process with escalated privileges where the user permissions are asked first through something like:

enter image description here

Niels Bosma
  • 11,758
  • 29
  • 89
  • 148

2 Answers2

2

You can use AppleScript to create a graphical authentication prompt:

#!/bin/sh
osascript -e "do shell script \"$*\" with administrator privileges"

Other methods: Is there any graphical "sudo" for Mac OS X?

Slava Knyazev
  • 5,377
  • 1
  • 22
  • 43
0

You could try the option -S of sudo for accepting the password from standard input. After use echo password and | to pass the password to the command:

echo myPassword | sudo -S installer -pkg /tmp/mypackage.pkg -target
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77