Run cron job with admin password

I need to be able to run the cron jobs of rotating the log files, but with the admin name and password hard coded into the script (and saved as run only of course).
I need to do this because our users don’t have admin access nor can they use sudo.

This is the script I want to use but what is the syntax to hard code in the name and password?

-- show a list of choices and store the result(s) in the_choice
set the_choice to choose from list {"Daily", "Weekly", "Monthly"} with prompt "Select Maintenance Scripts:" with multiple selections allowed
-- if the user presses the "Cancel" button it returns false
if the_choice is not false then
	-- perform appropriate tasks for each choice
	-- the_choice would be something like {"Daily","Monthly"} depending upon what the user has chosen
	if the_choice contains "Daily" then do shell script "sh /etc/periodic/daily/500.daily" with administrator privileges
	if the_choice contains "Weekly" then do shell script "sh /etc/periodic/weekly/500.weekly" with administrator privileges
	if the_choice contains "Monthly" then do shell script "sh /etc/periodic/monthly/500.monthly" with administrator privileges
	-- Tell the user that all the tasks were successful
	display dialog "Maintenance complete." buttons "OK" default button 1 giving up after 10
end if

is it something like “with username “baba” password “booey”?”

Thanks,
Chris

Hi Chris,

I recommend to invest 9.99$ in Macaroni.
It’s worth its price :wink:

PS: you need the parameters user name “username” password “¢¢¢¢”
to avoid the authentication window

So is this the exact syntax I would use?

if the_choice contains "Monthly" then do shell script "sh /etc/periodic/monthly/500.monthly" with administrator privileges user name "username" password "¢¢¢¢"

the AppleScript syntax is right,
but I don’t know, whether the shell syntax is correct

Cool. I think I just need to flip it, per another thread discussing sudo and also this: http://developer.apple.com/technotes/tn2002/tn2065.html

Thanks, Chris

this is how I perform the montly from my applescript

	do shell script "/usr/sbin/periodic monthly" user name AdminName password pword with administrator privileges