I have just completed my first really challenging (for me) UNIX shell script and I'm quite proud of myself. I run the Mac section of a very cross-platform lab at an art school in New York. We have all the Macs using network home accounts authenticating on a Mac OS X Server and mounting on an NFS mount point run from a Linux box (it's a long story). Sometimes, it's really convenient for me to have a standard flat BSD passwd file to give to the UNIX SysAdmin so we can sync up the user data between Mac and UNIX. The flat file is also very handy to have around if anything goes wrong with your user database. It can be used to very easily rebuild that database in the event of a catasrophe. Or if you just want to rebuild your server for fun without re-entering all the users and their passwords by hand.
Back in the NetInfo days this was no problem -- use nidump to generate just such a file directly from the NetInfo DB. As of Panther, however, Mac OS X Server uses LDAP exclusively for network home accounts. But I still need that flat file. Apple provides a command-line command called dscl, which will output certain data from the LDAP database, but it will not simply create a flat file like nidump would. So, I've written a script that uses dscl, foreach and (of all things) awk to create a passwd file from the LDAP database. I realize it's very sloppy (I'm sorry, but awk is INSANE) but hey, it works. And like I said I'm proud. Maybe someone else can use it. Or perhaps it's possible that I'm the only person in the world who needs to do this.
To use the script, view the source, then copy and paste all of it into a plain text file. Save it somewhere handy. Make it executable (chmod 755 /Path/To/File). Then just drag it into a Terminal window, hit return and type your password. If you have a large LDAP database, it will take a few minutes ... but when it's done, there will be a file on your Desktop called UserList-FINAL.txt. That's your passwd file!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040729201549396