This past weekend, I took advantage of OS X's UNIX core to automate the database backup for this site. Until recently, I backed up the data by connecting to the ISP, launching the mySQL database program, exporting the data, then using one of a number of transfer programs (Fetch, RBrowser, etc) to bring the file back to my home machine.
Although this worked, it was quite tedious, and I would often forget to do the backup. Then another geeklog-powered site had a major disaster, and lost all of their articles (macosxapps.com, if you'd like to stop by and help them rebuild, it'd be greatly appreciated!). This was the kick I needed to find a better way to do my backups.
Read the rest of this article if you'd like a little insight into how I used some basic UNIX programs to handle this repetitive mundane task. This is fairly basic stuff for UNIX wizards, and I'm sure I could be doing this in a more advanced way, but it does demonstrate how the UNIX core of OS X can be put to good use.
In an earlier item, links were posted to Jordan Miller's site on altering the images used by the LoginWindow app. If you want, you can carry this bit of fun to more of an extreme.
First, you will have to register as a developer and download the OS X developer tools (instructions are elsewhere on this site). Don't be afraid, you can do a bit of interesting stuff with Interface Builder if you are careful. You can change the size of the image, the colors/styles of the fonts, placement of the buttons, etc. You can see an example of this in the screenshot above. The original screen is at 1280x1024. The image is of the wonderful David Hockney work, Kyoto. It calms me down before I login.
If you'd like to know how to edit the login window extensively, read the rest of this article!
[P.S. -- Are there any Cocoa programmers out there that can tell me what loginwindow is doing that makes the purple background not be captured when I try to capture the screen content? Is it drawing the background directly to video memory? Is there a way to capture the whole shebang?]
If you use jEdit (see Favorites box at left) as your text editor, one of the cool tricks it performs is to maintain a history of your search and replace calls. If you command-click in the search or replace box, you'll get a drop-down menu showing the last 15 or so items you've searched or replaced. This little trick saves a bunch of typing if you're looking for the same thing somewhat regularly.
I installed Samba a while back to play with it, but I've since moved my OS X box to a non-Windows environment. I want to uninstall Samba just for general "system purity," but I can't find any uninstall directions. Any clues?
You can open any of the standard GUI applications (such as Mail, Explorer, Address Book, etc.) from a terminal session. Although this may not have great benefits in day to day use (why not just click the dock icon?), it does imply that you could write a shell script to open a GUI app, and then use the UNIX cron program to schedule the 'open' to happen on a shedule. If the GUI app you open then had some command it executed at startup, this might prove to be a worthwhile trick.
In any event, to open a command in the terminal, just type
For example, to launch the Calculator or the game, type one of the following:
open /Applications/Calculator.app/ open /Applications/GrabBag/chess.app
As I said, I'm not completely certain about why or how useful this is, but it is somewhat interesting. It even opens the application in the background, so you don't switch out of your terminal window.
A while ago someone asked about how to configure osx for printing from the command line.
If you have a postscript printer in your network, this is actually pretty simple. Create a printcap file (named "myprintcap" for example) with jEdit, or vi or emacs or any other text editor:
lp:\ :lp=:rm=<printer ip or name>:rp=lp:\ :sd=/var/spool/lpd/lp:ty=PostScript:
Save this file somehere in your directory. Note: there should be backslashes terminating the first two lines. They were consumed by the scripts processing this hint, I guess. [Editor's note: Backslashes get stripped out, unless you enter in HTML mode, and use the character code '\' for a backslash ... I've added them to the above lines.
Next you load this printcap into netinfo (line 1 below) and create the spool directory (line 2). Open a terminal and connect as root ("su"), then type:
When in column view in OS X, the final column is designed to present a 'preview' of whatever file is highlighted in the previous column - text, image file, whatever. I've found that its behavior in the PB is somewhat unpredictable - sometimes you see a preview of an image file, sometimes you don't; text files seem to work regularly. Tonight, though, I noticed for the first time that Quicktime previews work really well. If you highlight a Quicktime movie in column view, you get a mini Quicktime player in the next column with audio and video controls. Easy movie browsing without launching anything!
When this feature is ironed out in the final release, it could be one of the nicer usability touches in the OS.
I just stopped by The Computer Store, and had the sales rep look up Mac OS X in the Apple system. As of today, Apple has entered the part number in their systems, meaning that resellers can now take orders. So I reserved the very first copy at the Beaverton store.
I asked if they were going to do "Midnight Madness" for OS X. The rep told me he's not sure yet when they'll be opening on the 24th. He told me they opened at midnight for the OS 8 launch, and that was fine with Apple. But he also said they got in "a lot of trouble" with Apple over the iMac launch. I asked if they opened at midnight that evening as well. He said, grinning, "Well, it was midnight on the east coast!"
On a side note, they had one of the new G4 Titanium machines. This was my first chance to see one up close and personal. Incredibly thin, amazing screen, solid keyboard, and reasonably light. And the white apple on the cover glows with the light from the screen on the other side when the machine is on - a very impressive effect. Tempting, even though I have absolutely no need for one.
[UDPATE 2/2: As reported on the net, Apple has rolled out a PB rebate program; here's the text of the email that I just received:
"Thank you for being one of the pioneers who beta tested Mac OS X. Your feedback has helped make Mac OS X the world's most advanced operating system. To show our appreciation, we are offering you a $30 discount on the final version of Mac OS X.* You will also be among the first to receive Mac OS X when it ships on March 24, 2001. Again, thanks for helping to make Mac OS X the world's most advanced operating system."
I'm called (the online store system didn't work as described in the email) and ordered my $99 copy today, and will purchase a $129 version for work on Saturday the 24th - I'll keep the local dealer happy, and get a usable copy as quickly as possible!]
If you're a complete beginner to UNIX (as I still consider myself), you can use something called aliases to save yourself a lot of typing at the command line.
In the Mac OS, an alias is simply a pointer to another file. In the UNIX world, an alias is similar in concept, except that it's a command that points at another command. There are a few pre-defined aliases in the tcsh shell (the program that runs when you open a terminal). You can see these by typing
at the command line. One of the more useful pre-defined aliases is ll which replaces ls -lag for complete file listings.
Although the pre-defined aliases are useful, the real power is in creating your own aliases for your often-used commands. If you're new to UNIX and you'd like to learn about aliases and how to use them, read the rest of this article.