Hi,
I’m fairly new at applescripting. Using panther, my script would run a shell script as such that it would prompt for an administrator password (in a dialog box) and then execute. Now that apple has changed the “do shell script” to run as setuid-root instead of root itself, I’m stuck.
Paste this into script editor:
do shell script “route add -net 10.174.0.0/16 10.170.78.1 2>&1” with administrator privileges
Note: this is only part of a larger script that involves other functions which still work well since they don’t need “root” privileges.
I now error out stating I need to run this as “root”. I have tried various combinations such as eliminating “with adminstrator privileges” and adding “sudo” before the “route add”, etc. What I need is a way to execute this with a prompt from the system to enter my root password.
I have to execute this script when I go into the office and connect to my company’s network.
Has anyone found a work around for the change to setuid-root when running “do shell script”. I’d really appreciate some help with this.
Model: Powerbook G4 AL 1.67ghz
AppleScript: 2.1
Browser: Safari 312
Operating System: Mac OS X (10.4)
The ‘with administrator privileges’ should handle the authentication and provided you’re in the admin group you should be able to execute this command by entering your own user password.
Under Tiger, ‘do shell script’ accepts an additional parameter ‘username’ which lets you authenticate as a different user but, again, if you’re in the admin group the code as you have it should work.
set boomerang to "perl -Ue '$< = $>; system(@ARGV)' "
set the_script to "route add -net 10.174.0.0/16 10.170.78.1 2>&1"
do shell script boomerang & the_script with administrator privileges