Setting up script for school macs

Hi, I’m new to applescripting. I’ve been reading the beginner’s tutorial (which is very helpful, btw) and I’m about done with it now so I have some idea of how applescripting works. Anyways, I’m working for the computer center at my college over the summer and we have a number of random things to do – cleanup, organizing, logistics sort of stuff. One of the assignments I was given was to learn applescript (pretty sweet job, eh?) and then create scripts that will be put in all our macs and which do 2 things:

  1. It has to retrieve the user’s account from the school’s server. We have to log into all our computers with our accounts, macs or not, so the macs are already connected to the school’s server under the user’s info. The only thing is that their user folder on the server isn’t easily accessible. I think this script should be easy enough. I played around with the record function on the scripter and it would be very easy to bring up my user folder. The only thing I have to do to the record code is to replace the directory “student 06” and then folder “schen” to whatever happens to be the current user’s account info. So I need a way to retrieve that information, set it to a variable, and replace the directory designations.
  2. The other script I have to make is to set up a whole standard or prototype setting for every mac for when students log on. That is, there is a certain background, certain applications available, certain things on the desktop, etc. that comes as default for all students who log in (then I’d assume we’d make a different one for faculty and then staff). This seems to me considerably harder to do than the first script because I’ll need to learn a lot of different commands to do the variety of things we need to set up.
    Then of course, I’ll have to set it up so these scripts run upon a user’s logging in. We can then freeze the computer so nobody can mess with the script.

I was wondering what you guys thought about this project. Is it even doable for a beginner like me? I did some programming in high school and I remember some of the principles of programming (i was excited to do the if then tutorial; i love if then :p). Also, I’m about done with the beginners tutorials and I was wondering where I’d go from there. Should I just play around with the scripts you guys have on this forum? If you guys have any ideas or suggestions about my project that would be greatly appreciated. I came into this not knowing anything really about how it would turn out, and now it seems like a more and more daunting task.

Specifically, though, I think I may be ready to tackle the first script if I knew some more commands, look around the language directory or something. I need to know how to retrieve the user information though. Anyways, if you guys don’t mind I’ll be posting my attempts up here for help as I work on this.

I am also new to AppleScript, working on learning it for personal enrichment and also for work; I’d be very interested in seeing your first script in particular. How/where are your home drives stored, and what method are you using to access them?

There is about a 40% chance I will be asked to make a similar script in the very near future here at work.

Well I think I’ve got both scripts more or less figured out. There’s just a few holes to fill and some commands to learn. Both of them have to rely heavily on the do shell script command cause I can’t figure out another way to have applescript do anything with networking. (I’m assuming by home drives you mean the student’s home folders on the school’s server (sry I’m not clear on terminology)).

  1. For the first one I have to make users connect to our server on login. I tried doing a record and going to Finder → Go → Connect to Server. But that doesn’t work since appscript doesn’t recognize anything past Finder. I figure there’s a way to o the same thing in Terminal, which my boss is looking into. Then we have to figure out where the mac keeps the user info once the user has logged in. Since we’re freezing the computers it’ll be temporary. Once we have that we should be able to set it to a variable, or just put it all on a shell script and call that from applescript. (The do shell script command can send commands directly to the terminal, but it act as if opening a new terminal everytime you enter the command in appscript, so instead you can create a shell script separately as a text file, save it, and then call it with the do script command from script editor – it’s in the standard additions library if you want to look into it).

  2. This actually turned out to be the easier one. We found out that we can create a skeleton user account manually, and then use the terminal to set all user accounts to that skeleton account. Since all user accounts for students would be temporary on any mac, we can just run a shell script on login through applescript and it will change the student’s account settings to that of the skeleton account. All the actual commands are done through the terminal, so all I have to do with applescript is to run the shell script.

Once I finish this project I’ll be happy to send you the scripts, but I still have some problems to work through:

–Is there a command I can include in the script to run it on startup, or login? Or is there a way to do this manually on macs?
–With do shell script there are the properties administrator privileges, username, and password, but as far as I know you have to first answer the username/password prompt before applescript saves the usernme and password. Is there anyway I can set the password and username within the script before it runs?
–I can open certain windows (I was playing around with record), such as “set target of Finder window 1 to startup disk”, which refers to the mac HD, but there is no equivalent for the servers under SHARED. When I try to do the same record to get to a folder within the school’s server, I get this instead: “set target of Finder window 1 to folder “” of folder “””. Is there some other command or way to access folders in shared networks?

btw I really appreciate any help, so thanks a lot. this is rly a great resource

Hi,

there is a command mount volume in Standard Additions

put the script in the startup items of each user. A global startup item is a bit more complicated because it must run with certain privileges

define properties in the script (predefined variables), or retrieve the data from the keychain with Keychain Scripting

You can open folder windows with


tell application "Finder" to open folder "Disk:path:to:folder:"

but in most cases there is no need to deal with Finder windows, files and folders can be accessed directly with the Finder or, in case of shared volumes, better with shell commands.