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??
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.
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.