[Pythonmac-SIG] Appscript/administrator privileges

Bob Ippolito 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 
>>>> to
>>>> 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 
>> /Applications/DarwinPorts/TkDarwinPorts.app/Contents/MacOS/Wish\\ 
>> Shell"
>> 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. [1]
> [1] Though if you had to, you could call the 'do shell script' osax 
> from MacPython using the osax module 
> <http://freespace.virgin.net/hamish.sanderson/osax-0.1.0.tar.gz>.
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[1].

[1] Not that you should ever use popen, because the subprocess 
<http://www.python.org/dev/doc/devel/lib/module-subprocess.html> module 
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 mailing list