osx - How to "do shell script with administrator privileges" as a regular user and not as root? -
i'm running applscript runs shellscript through terminal.
i want able use "do shell script administrator privileges" terminal runs script root, , not regular user (which admin).
the reason want run not root (except obvious reasons) use ~ sign user can log in , run script locally (f.e. write log file straight user's desktop).
the other reason want run not root because use visex installer during shell script not run root.
this applescript use (thanks regulus6633 applescirpt):
set thefile "myscriptname.sh" -- launch application admin privileges , pid of set thepid (do shell script "/applications/utilities/terminal.app/contents/macos/terminal > /dev/null 2>&1 & echo $!" administrator privileges) integer -- bundle identifier of pid can application delay 0.2 tell application "system events" set theprocess first process unix id thepid set bi bundle identifier of theprocess end tell -- runs terminal shellscript set thefilealias (posix file thefile) alias tell application id bi activate open thefilealias end tell
unfortunately, with administrator privileges
means "as root". in mac os x, in other unix-derived operating systems, there's no way administrator privileges non-root user. when run via sudo
, runs command root.
you don't need run entire terminal window root, though. launch terminal regular user , tell (via do script
inside tell application "terminal"
block) execute desired command root. don't know offhand if do script
accepts with administrator privileges
, if not, can stick sudo
on front.
Comments
Post a Comment