I made a note about these commands a while back while trying to find a solution to setting the default printer via ARD. They might come in handy some day…

  • lpstat -p will show you the printers available
  • lpstat -d will show you the current default printer
  • lpoptions -d printername will set the default to whichever printer you specify
Posted in Apple No Comments leaf

Jobs Vs. Gates

  • Apple
  • Windows

gatesvjobs.jpg

Good stuff.  This cartoon captures both Jobs’ “too hip to be a nerd” and Gates’ “too nerdy to be hip” images.  Guest appearance by Commodore 64!  Pic links to YouTube video.

Posted in Apple, Windows 2 Comments leaf

Invisible Volume in OS X

  • Apple

I am currently installing 10.2 on some old Blueberry iMacs. I came accross an error that said something to the effect of “The destination is not within the first 8 GB of the hard disk”. Ok then. After some searching, I find that the solution is to partition the drive, and install the OS on the first partition, which you have partitioned to a size smalled than 8 GB. Apparently, this monster 20 GB aftermarket drive is too much for 10.2 to handle as the OS drive. Now I realize I have seen this error before, many years ago.

After partitioning and installing the OS, I boot the machine and see the two hard drives. Personally, I have no problem with this. I often have 5 or more drives mounted on my desktop. But where this computer is going, this will be an issue for the user. Now I start looking for a solution to hide this second volume. I came accross this solution. But it requires that I install developer tools. I am not going to try and do that on a G3. So I just tried something simple, formatting the volume with a leading period. A leading period will hide a file in UNIX, OS X is built upon UNIX, why not. It works! So if you ever want to make a volume disappear in the finder (VM drive, backup drive, “don’t confuse the old people with two hard drive icons” drive), format with a leading period. You can of course still access the drive via command line.

invisibledrive.jpg

.Awesome

Posted in Apple No Comments leaf

When it comes to file manipulation in OS X, I find myself using these three commands often, and usually in combination. Almost every time I use them however, I have to reread the man pages, and review regular expressions. I end up googling the same things and ending up at the same pages, so I wanted to make a single post that will contain all the information and links necessary. Here we go…

GREP

grep searches the named input FILEs (or standard input if no files are named, or the file name – is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.”

AWK

Awk scans each input file for lines that match any of a set of patterns specified literally in prog or in one or more files specified as -f progfile. With each pattern there can be an associated action that will be performed when a line of a file matches the pattern. Each line is matched against the pattern portion of every pattern-action statement; the associated action is performed for each matched pattern.”

SED

“The sed utility is a stream editor that reads one or more text files, makes editing changes according to a script of editing commands, and writes the results to standard output.”

REGULAR EXPRESSIONS

Regular expressions allow you to use variables in your commands. Most of us are at least familiar with *, where *.db means “every file ending in .db”. There are however many useful regular expressions, and they are the key to executing the above commands efficiently. Brush up on regular expressions here.

PIPES AND REDIRECTS

In order to send the results from one command to another command you need to “pipe” them together. An example:

cat *.txt | grep "blatti.net"

cat *.txt will display the contents of every file that ends in “.txt” to the standard output. By piping those results, they become the input for the second command. grep "blatti.net" will take the standard input, and display each line that contains “blatti.net” on the standard output. So when these two commands are piped together, we will get every line that contains “blatti.net” in every file that ends in “.txt” in the working directory.

While most of your work can be done with standard input and output, you’ll probably want to write your results to a file. Enter redirection. Using the example above, lets say we wanted to take our results and write it to a file. This is done with the > redirector.

cat *.txt | grep "blatti.net" > results.txt

This command will take every line that contains “blatti.net” in every file that ends in “.txt” in the working director, and write them to the file “results.txt”. Note that this will overwrite any existing “results.txt” file that exists in the working directory. Which begs the question “What if I want to append instead of overwrite?” Well then use >> instead of >. The >> redirector is especially useful if you are creating logs.

Now you too can create obnoxious commands with limited knowledge! The command below is one I created using the resources listed in this article. It is part of a piece of software that pulls text out of a PDF and returns a specified section in a text file. (I’m sure it is inefficient – so someone chime in and tell me how to make it better so I’ll know for next time)

sed 's/^[0-9]$/Period &/' /tmp/skypdf.txt | sed 's/[A-Z]*$/&,/' | sed '/Period/G' | sed '$!N;s/\\n/ /' | sed '/Period/{x;p;x;}' | sed 's/^ //' > ~/Desktop/full.txt"

Now say that 10 times fast!

Posted in Apple 1 Comment leaf

isyncandiquit.jpg

Now that I have comitted myself to OSX, I had to start using iSync to sync my Treo with my Address Book and iCal. For some reason this is still a goofy process.

  • You open iSync
  • You tell iSync to begin the sync process
  • iSync asks you to start initiate a sync with the Palm software
  • Conduit Manager syncs some things with iApps (iCal, Address Book) and others with Palm Desktop (Pictures, Phone call DB)
  • Conduit manager completes the sync and quits itself
  • You manually quit iSync

Again, there has to be a better way to do all of this. Unfortunately I have heither the ambition or know how to fix the entire problem, so I’ll tackle what I can fix. Everytime I open iSync, I want to sync my device. Everytime the sync is complete, I want to quit iSync. Enter iSyncandiQuit. Simply run this application and it will launch iSync, initiate a sync, and upon completion of the sync, quit iSync and itself.

Posted in Apple 1 Comment leaf

benchwarmer.jpg

Benchwarmer is a simple backup application designed for basic users. It allows the user to backup some critical elements of their home directory including:

  • Mail (including prefs)
  • Address Book (including prefs)
  • iCal (including prefs)
  • Desktop
  • Documents

This data is backed up into a single ZIP archive on their desktop. Please leave any questions, comments, or requests as comments on this post. Thanks.

Download Benchwarmer HERE.

Posted in Apple 7 Comments leaf