Can I get some tips for a simple script??

I’m a total newb with applescript, i have a question that hopefully will get a simple answer:

Long story short, i have a shell script that refreshes a user’s home directory. It works great. Now, I have 3 users, Student, Faculty, and Staff. (I run the scripts logged in as root).

I have multiple applescripts that will call the appropriate shell script (ie, refresh_student.sh, refresh_faculty.sh). So if I run the applescript called Student, it calls the refresh_student.sh. You get the point.

What I want is one applescript that, when run, prompts me as to which of the 3 original scripts I would like to run (ie. it says something like “Which user would you like to refresh? • Student •Faculty • Staff • All”) With the bullets being either radio buttons or checkmarks. Then a “Go” and “Cancel” button.

Is this possible? If so, could I get your best layman’s terms on how to do it??

So much appreciated…

Would something like this be sufficient? It allows you to make multiple selections.

set shellScripts to {"refresh_student.sh", "refresh_faculty.sh"}
set scriptsToRun to (choose from list shellScripts with prompt "Which user would you like to refresh?" with multiple selections allowed without empty selection allowed)
if scriptsToRun is false then return

repeat with script_ in scriptsToRun
	do shell script script_
end repeat

It might need to be modified to include the path to the scripts in the do shell script command.

– Rob (not a shell expert)

Oooh, Rob, you just beat me!

Jon

You guys rock, I’ll give it a try. If I have problems, I may be back!!!

Thanks :lol:

Good so far, except a bit cloudy on the syntax of one part:

Jon, the script runs, but something is not working. I think it has to do with the line :
– do shell script the_choice

I don’t have a fourth shell script, so what is this referring to?

if the_choices contains “All” then
–do shell script “Student”
–do shell script “Faculty”
–do shell script “Staff”
else
repeat with the_choice in the_choices
–do shell script the_choice
end repeat

Script runs well, except it doesnt refresh my users. My shell scripts work on their own, so something isn’t being called correctly.

[/quote]

The lines starting with “–” are just placeholders for you to put in your code for running your shell scripts. You said you have AppleScripts that run your shell scripts, so just substitute your code for running the scripts in each of the lines starting with “–” being sure to modify it so that it runs the proper script based on the choices made in the choose from list.

So, your code would look something like this:

Jon

Sweet, it works well.

I surely appreciate your help!!!