[Pythonmac-SIG] Appscript/administrator privileges
bob at redivi.com
Sat Nov 27 12:47:07 CET 2004
On Nov 27, 2004, at 6:17 AM, has wrote:
> Bob Ippolito wrote:
>>>> Does appscript support anything analogous to AppleScript's ability
>>>> execute a command with administrator privileges (hooks into
>>>> Authorization Services)?
>>> Can you give an example?
>> (from one of Kevin's posts on the darwinports list)
>> set theLauncher to "sudo -b
>> do shell script theLauncher with administrator privileges
> Ah, right. The Python equivalent to 'do shell script' is os.system()
> so it's not an appscript issue. One for Python's Unix experts, I
> think. 
>  Though if you had to, you could call the 'do shell script' osax
> from MacPython using the osax module
The typical unix way would be via Authorization Services, which can be
done with the Authorization extension that I wrote, as he mentioned.
His question was specifically if he could use the same facility that
AppleScript uses for this via appscript, which you answered in the
footnote. FWIW, "do shell script" is a lot more like os.popen.
 Not that you should ever use popen, because the subprocess
is a much better way of handling said situations. It's sad that "do
shell script" won't take a list of arguments.
More information about the Pythonmac-SIG