Thursday, June 11, 2009

User creation script

A consultant recently asked me for a copy of a script I created for our school to automate user creation. I thought it would be more useful for myself and the world if I just archived it here where I can always find it, and where other folks can use it (I find it much harder generally to find usable sample window code &c. than I do with linux).

These are my first (and hopefully last) scripts in virtual basic scripting. I'm putting them here to make it easier to share them, but these haven't really been prepared properly for sharing (I was simply working from examples until these worked). Obviously it would be worth setting these up with tweakable parameters up top at some future point.

Script for creating students


Create Users



This script creates student user accounts based on a CSV file with the following structure:

username, first, last, group, password


' Script to create student accounts
' Created by Tom Hinkle
' (or, if he's moved on,
'
' Requires file named students.csv in same directory with requisite information.
'
' File format is plain csv (no escaping) as follows:
'
' username, first, last, year-of-grad, password
'
' Note that year-of-grad is used for group names. We expect there to be an OU
' with the name of e.g. YOG2012 for each year-of-grad. Also, student folders
' are named by YOG, so we expect the students folder to contain a folder titled
' e.g. YOG2012

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
upnSuffix = "cpcs.com"
Set objRootDSE = GetObject("LDAP://rootDSE")

dim fs,objTextFile
set fs=CreateObject("Scripting.FileSystemObject")
dim arrStr
set objTextFile = fs.OpenTextFile("students.csv")

Do while NOT objTextFile.AtEndOfStream
arrStr = split(objTextFile.ReadLine,",")
givenName = arrStr(1)
lastName = arrStr(2)
sn = lastName
cn = givenName & " " & lastName
OU = "YOG" & arrStr(3)
samAccountName = arrStr(0)
' Specify the NetBIOS name of the domain.
strNetBIOSDomain = "cpcs"
userPrincipalName = samAccountName & "@" & upnSuffix
homedir = "\\mms1.cpcs.com\students\" & OU & "\" & samAccountName
groupname = "LDAP://ou=" & OU & ",ou=Student,DC=CPCS,DC=com"

Set objContainer = GetObject(groupname)
Set objUser = objContainer.Create("User", "cn=" & cn)
objUser.Put "sAMAccountName", samAccountName
objUser.Put "userPrincipalName", userPrincipalName
objUser.Put "sn", sn
objUser.Put "givenName", givenName
objUser.Put "displayName", givenName & " " & sn
objUser.Put "userAccountControl", 512
objUser.Put "homeDirectory", homedir
objUser.Put "homeDrive", "H"
objUser.Put "scriptPath", "SLogon.bat"

On Error Resume Next
objUser.SetInfo
If (Err.Number <> 0) Then
Wscript.Echo "Unable to create " & samAccountName
End If
'On Error GoTo 0


objUser.SetInfo
objUser.SetPassword arrStr(4)
objUser.SetInfo



' Create folder, based on:
' http://www.eggheadcafe.com/software/aspnet/30289055/modifying-user-home-direc.aspx


If (objFSO.FolderExists(homedir) = False) Then
' Create folder.
On Error Resume Next
objFSO.CreateFolder homedir
If (Err.Number <> 0) Then
Wscript.Echo "Unable to create home directory for " & strSAM
End If
On Error GoTo 0
End If
If (objFSO.FolderExists(homedir) = True) Then
' Assign permissions to home directory.
intRunError = objShell.Run("%COMSPEC% /c echo Y| cacls " _
& homedir & " /T /E /C /G " & strNetBIOSDomain _
& "\" & samAccountName& ":F", 2, True)
If (intRunError <> 0) Then
Wscript.Echo "Unable to assign permissions for " & samAccountName
End If
End If
Loop
objTextFile.Close
set objTextFile = Nothing
set fs = Nothing
wscript.Echo("When you are done, you will want to go into active directory, highlight the new users manually, and add them to the group Students. You'll also need to disallow changing the password. Sorry I didn't get this done programmatically, but it's relatively simple to do manually")

Saturday, May 16, 2009

Does it count as unvoiced if the whole word is whispered?

Needless to say I've been excitedly tracking Grace's acquisition of various sounds as she learns to speak and I've been waiting anxiously to hear her first unvoiced consonant.

The other day, we came to a fine page in a book with the following text:

"The PIG is driving the tractor... putt-putt-putt..."

The putt-putt-putt is supposed to be a tractor sound (there are round poofs of smoke which illustrate the rhythm going out of the tractor tailpipe).

Grace finds this page highly entertaining, enough so that she echoed back:

"PUH PUH PUH PUH PUH!"

It was the first time I ever heard a clear "P" from her, so I was very excited. But then I realized she had whispered the rest of the word (a shouted whisper).

Oh well.

If you're curious, Grace's consonants so far are roughly as follows...




Grace's sound, roughlyPhonemes she uses the sound for (in rough "English-y" notation)
stops
d/t/ and /d/
b/b/ and /p/
nasals
n/n/
m/m/
fricatives
ʒ (zh)/s/, /z/ /ʃ/ (sh),/tʃ/ (ch) /dʒ/ (j)
approximants
ɹ (some version of it)/ɹ/ (r) and /w/
funny sounds
p/p/ in a whispered tractor sound
r* (coronal trill)Used consistently for what a duck says -- I have no idea why
[ʙ] (bilabial trill)Used joyfully and frequently for silliness
r̼ (linguolabial trill)Used joyfully and spitfully for silliness

*Katharine things this might be [ʀ] (uvular trill), which would make some more sense of it since this at least has her tongue somewhere close to the position needed for a "quack" sound (velar plosive)

Wednesday, May 13, 2009

Now that's style...

From google docs...

The bad news is that Google Docs has just encountered an error.
The good news is that you've helped us find a bug, which we are now looking into.

This is actually a bit annoying as I'm using google docs for a time sensitive assignment... but nonetheless, I appreciate their astonishing dedication to the half-full glass. I should work on some error messages like that for Gourmet.

Friday, April 10, 2009

Two experiences with customer service, a world apart

Since we've gotten two new gizmos here over the past month (dell mini + kindle2), I've had a few chances to enjoy giant-corporate phone support. At times past I've felt like all companies end up being equally frustrating, but my recent experiences leave me feeling otherwise. Here's a look at two very different experiences -- Amazon and Dell.

Dell:

I had various issues with my dell laptop's ubuntu installation out of the box. First, the weekend I got it, the Dell software repositories were down for a few hours, so no kind of update or installation would work at all (I had no way of knowing at the time that this was a temporary problem). Next, a number of things weren't working too well -- the machine had crashed several times (more than any linux machine I've ever used before), ssh was not working (so I couldn't copy all my working files from my other machine over our network), and I had found a reproducible bug that crashed the dell launcher every time I changed the background. Finally, I had questions about whether and how to update the machine from 8.04 (what it came with) to 8.10 (what is current); the standard ubuntu procedures didn't seem to be supported, but it seemed like it would be worth trying an update to see if it fixed some of the issues I was experiencing.

I went to Dell's website to see what I could see. I found a phone number and a chat support link. I called the phone line and opened up the chat support, figuring I'd learn which was faster. The chat took about 10 minutes to connect me with a service representative. I had to type in the service code from the back of the computer, etc., before I could describe my problem to them. When they learned the issue I had was with their ubuntu set up, they informed me I had to call a phone number (a different number than the one listed in my docs on the machine and on the website). At this point, I hung up the phone (I was on hold all this time) and called the new phone number. I was on hold on the order of 45 minutes before being connected to a service representative, to whom I had to read various serial numbers off of my laptop etc. When she learned that I needed support with their ubuntu installation, she told me I needed to talk to their ubuntu experts who were only available from 10-5 (it was 9:50 at this time -- I'd been trying to get support for over an hour at this point).

At 10, I did try calling the number I'd been given again, but when I heard tones and a computerized voice saying "you're being forwarded", I got suspicious I'd been moved out of the ubuntu support area anyway, and gave up entirely.

Amazon:

Katharine's new kindle developed a dead pixel (or rather, a dead line -- a whole one-pixel-wide vertical line of white) some time a few weeks ago. When you're reading, you barely notice it, but it's the kind of thing that's worth getting repaired while it's under warranty.

Today I decided to get around to calling support. I googled "amazon kindle support" and the first web page I found informed me that I could call, or I could sign in with my amazon account and have them call me, in which case they'd have all of my information ready. That sounded better to me, so I signed in under Katharine's account (to which the kindle is registered). I chose "hardware defect" from a dropdown menu of potential problems, chose "now" from a menu of times at which I'd liked to be called, entered my phone number, and clicked "Call me".

A window popped up telling me the phone was ringing and sure enough my phone rang. A computer voice told me I'd be waiting for 1 minute. In a few seconds I got a human. He confirmed that I really was Katharine by asking for my name and address (okay, I'm not Katharine, but I know enough to fake it). He talked me through how to hard reboot the kindle. I was pretty sure this wouldn't do anything, and sure enough it didn't. He confirmed that this sounded like a hardware issue and said a replacement kindle would be in the mail today and would most likely arrive by Monday. He said an email would go out to Katharine with tracking information, information on sending the defective kindle back, and directions on registering the new kindle to her account.

The whole process was done in just under 9 minutes (my phone has a timer, so I know).

Conclusions:

In both cases, I was calling tech support for a new product (Dell has just released the Mini-12 with ubuntu, within the past few months; the Kindle2 is under a month old), so in both cases the support training etc. must be relatively fresh. But the design, polish, and programming behind these two systems was worlds apart.

In Dell's case, they seemed determined to disappoint at every step. Their advertised 24/7 support does not apply for software issues. Add to that a slew of technical problems in their ubuntu setup and you have a lot of frustrated ubuntu users. But when you try to access them through their phone and chat support, you get bounced around on the phone with no indication of where you are, how long you'll be there, or how close you are to getting help.

Amazon doesn't offer 24/7 support either, but when you go to their website, it's very clear what they do offer (the hours are right there). They also make it easy for you to save them time and money by having them call you after you've logged in, which gives them all of your account information and so on and prevents you from having to read awkward serial numbers in on the phone. The minute I got on the phone, Amazon gave me an estimate of how long I'd be waiting, so I knew whether I should settle into some other task while on hold or not. When I got a hold of a representative, the representative already knew everything about me, so all I had to do was confirm my address (I didn't need to spell anything out since he surely had the info in front of him on a computer screen).

Dell obviously understands that phone support is frustrating -- they've added chat support which is surely cheaper for them to implement and less annoying for many customers. But they haven't linked any of this to your account information (which would bypass all of the serial code reading), and they haven't linked their website directly to their phone system.

I realize Amazon had a lot of advantages in this comparison -- a hardware problem is easier to diagnose and support than a software problem; they also obviously had more call center people on hand when I called. That said, a lot of this is simply a question of design. Even with the same resources, I'd imagine if Amazon had designed Dell's system, my experience would have gone something like this:

1. I go the Dell website, log in under my account, and then say I need support.
2. I answer a few quick questions (drop-down menus) that determine that I have a software problem and I have the Dell-supplied Ubuntu 8.04 operating system.
3. I come to a screen that tells me that Ubuntu support is available from 10-5. I can either call a phone number listed there, or enter my phone number to have Dell call me at a specified time between 10 and 5. I click "call me at 10"
4. At 10:00 I get a call with an estimated wait time. Presumably even with the same staff, my wait time will be substantially less now that my call has been directed correctly, since their phone support people aren't being tied up redirecting misdirected customers, having people read out serial numbers, and so on.

Surprisingly, the redesign would actually improve my experience by replacing two human-to-human interactions that I had with computer interactions: first, instead of chatting with a person, I could have used a dropdown menu to tell them the nature of my problem; second, instead of waiting on hold to find out when software phone support was open, the web page could have told me. I know humans are normally nicer to talk to than computers, but when all you want is to give some basic information, a well designed form is much better than a human you have to wait to talk to.

A final note: I have no idea how good the Dell techs are at troubleshooting and supporting you over the phone, because I never got to one. Now that I know it takes upwards of an hour to contact them, I'm highly unlikely to call their support again.

Luckily, google has a plethora of information about all things linux, so I was able to learn a few key things that Dell support likely wouldn't have known anyway, such as how to fix ssh on their install (which is broken by a broken wireless setup by default), how to activate ubuntu repositories properly for the low power intel architecture dell shipped with, and why upgrading to 8.10 won't work yet (even though a Dell salesperson told me she was pretty sure it would).

Friday, April 3, 2009

I'm famous...


So my new Dell laptop arrived today with ubuntu out of the box... it's cool to see my sudoku game there among the games that come by default.

To think, a few summers ago Katharine gave me a sudoku on the beach... and now Dell is using my work for free...

Monday, January 19, 2009

Weekend in food


So this weekend in food I...
  • Made injera (or rather I made an injera hack -- made with regular wheat flour and only a half-day's fermentation). Injera + a nice flavorful stew + lentils + a couple of pastes/sauces to add more heat for the grown-ups made for a highly entertaining meal. For Grace, I just spread the bread on her placemat and spooned lentils, meat, etc. onto her plate. For once we were all eating with our hands, so she was right in place. Though the flavor was off, the texture of the injera was just right, and the whole point is that it does such a good job soaking up the other flavors anyway. Once the meat and sauces hit the bread, it was pretty awesome.
  • Made two loaves of raisin bread with Grace. Making bread is becoming a tradition -- she loves helping me knead. We ate one loaf almost instantly, but still haven't cut into the other. It will make nice toast whenever we break into it.
  • Made brownies with the Obama logo on them for tomorrow. I actually made two pans -- one round with the Obama logo and one square, on which I attempted to do an Obama silhouette. I had to abandon the silhouette, which resulted in a vague blue and red tie-dye look... oops. I'll be cutting those into squares so they look less like a screw up.
That's just a start. Also in the fridge for lazy nights this week are left-over roast chicken and vegetables and some multi-grain pancakes to cook up tomorrow morning (we have a tradition of making real breakfast on Monday mornings to take the edge off -- since it's a three-day weekend we'll push that to Tuesday.

All of this is pretty firm evidence that I had a boatload of work to do this weekend... nothing like procrastination to make me ambitious in the kitchen.

Saturday, January 17, 2009

Lullabies

It turns out that if I limit myself to the first five frets of the guitar, I can put Grace in the sling, sit in my desk chair, and play. Luckily the arrangement of the Brahms lullaby I've worked out is easily played in the first five frets.

Sweetest thing in the world: watching your baby fall asleep on your shoulder while you play.