Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Programmable screenshot utilities UNIX
The usual screenshot utilities, both built-in and third-party, never seemed to do what I wanted. Fortunately, Apple has provided three command-line utilities, screencapture, sips, and pbcopy, which can be combined in scripts to do exactly what I want.

An example script--which takes a screenshot (window, selection rectangle, or entire screen), resizes it to a given size or scale, saves it with a given filename, uploads it via FTP to a specified site, and puts the new file's URL on the clipboard--is described on this page.

[kirkmc adds: We've covered these command line utilities in various tips here in the past: screencapture, sips, and pbcopy, if you're interested in seeing what else you might do with them.]
  Post a comment  •  Comments (1)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[6,231 views] Email Article To a Friend View Printable Version
10.4: Create multi-partition Boot Camp disks UNIX
Tiger only hintIt turns out that part of the 10.4.6 update was the inclusion of non-destructive partitioning in diskutil, via the new resizeVolume option.

You can use this feature, for example, to create a Boot Camp setup with more than two partitions. For an explanation, see this entry on bbum's web site.

[robg adds: This will only work on GPT (GUID Partition Table) disks, which are what you'll find in an Intel Mac. I used Disk Utility to format a FireWire drive with GPT, then used diskutil to try to resize it on the fly. I think this should work, but I was having issues with the sizing of the partitions, resulting in an error. Given more time, it should be possible. Disk Utility, however, does not seem to support the non-destructive option, even on GPT disks.]
  Post a comment  •  Comments (10)  
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[37,212 views] Email Article To a Friend View Printable Version
A script to automate clamav package updates UNIX
ClamAV is an open source antivirus product. You can update the virus definitions by running the command freshclam in Terminal. The only shortcoming of the packages is that when the clamav package itself is updated, you have to surf to the sourceforge site, download the latest tarball, compile it and install it.

This shell script automates all of this:

#!/bin/sh
############################################
## Documentation:
## This script downloads the latest version of clamav and installs
## it. I've used the download mirror in Phoenix Arizona. You should
## modify the url variable to the mirror closest to you.
############################################
url="http://easynews.dl.sourceforge.net/sourceforge/clamav/clamav-"
latest=`lynx -dump "http://www.clamav.net/stable.php#pagestart" \
| grep "   clamav" | awk '{print $2}' | head -1`
wget $url$latest.tar.gz && \
printf "The latest version of clamav or %s has been downloaded!\n" $latest && \
tar zxvf clamav-$latest.tar.gz && \
cd clamav-$latest
./configure &&
make && \
sudo make install && \
printf "Ok I am updating to the latest virus definitions for \
version %s by running freshclam.", $latest && \
freshclam && \
cd ..
rm -rf cd clamav-$latest

[robg adds: I haven't tested this one -- there's also a GUI version of ClamAV for OS X called ClamXav, if you'd like to try it out without the command line work.]
  Post a comment  •  Comments (12)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[16,615 views] Email Article To a Friend View Printable Version
Watch Star Wars Episode IV in ASCII via Terminal UNIX
Open Terminal and type...
telnet towel.blinkenlights.nl
...to watch Star Wars Episode IV in it's entirety in ASCii characters!

[robg adds: I thought we had run this one before, but a quick search proves my memory is failing after 8,600+ hints...]
  Post a comment  •  Comments (16)  
  • Currently 4.11 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (9 votes cast)
 
[112,473 views] Email Article To a Friend View Printable Version
Play Chess from Terminal.app UNIX
I couldn't find anything on macosxhints.com, so I thought I would post this. In Terminal, navigate into the Chess.app package:
$ cd /Applications/Chess.app/Contents/Resources/
You'll find that Chess.app is based on the free chess program Sjeng (version 11.2). So you can play it in the Terminal, if you wish. Just type ./sjeng (link to it for easier access), and have fun!

Does anybody know how to make it play against gnuchess (via xboard)? It would be cool to see the winner!!
  Post a comment  •  Comments (4)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,172 views] Email Article To a Friend View Printable Version
Restore PHP, MySQL, etc. after a fresh OS X install UNIX
Yesterday, when I tried to run the 10.4.6 updater on my Dual G5, it locked up just before the end of the progress bar -- all apps went spinning beachball, and force quit had no affect. I had no choice but to power down manually, after waiting about 45 minutes to make sure it was really and truly locked up.

When the machine rebooted, it booted onto another partition, which was running 10.2.7. That was a bad sign. The 10.4 partition showed up, and all data seemed usable. I quickly made another backup of my key user files (even though I was current as of the day before), then set out to fix the drive. Disk Utility found and fixed a couple problems, but I still couldn't select the partition as my startup drive. Disk Warrior wasn't able to rebuild the directory -- it hung on the final "writing new directory" step. Stumped at this point, I could have restored an old clone, but there's well over 100GB on that partition, and that would take a long time. So instead, I opted to do an archive and install of OS X, with the Retain User Settings option enabled. This archives your current OS X installation, installs a new copy of OS X, then moves all your user data into the new system.

After rebooting and running the Combined 10.4.6 Updater, along with about 15 other updates, the machine was basically perfectly healthy again -- except for the various Unix bits I had installed myself -- things like customizing my Apache configuration file, all my web site stuff in the WebServer directory, my MySQL installation (along with all the databases), and my PHP installation (I use the version on entropy.ch, not the bundled PHP). All of these things live in the Unix side of the system, which was obviously wiped clean with the new OS X install.

Getting them back was relatively trivial, but I thought I'd take a few minutes to document what steps I took...
read more (306 words)   Post a comment  •  Comments (15)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[15,707 views] Email Article To a Friend View Printable Version
10.4: A c-shell alias for searching via Spotlight UNIX
Tiger only hintThis hint is motivated by this earlier hint, and other stuff I've read elsewhere. I created a csh alias to search via Spotlight. Results are returned in chronological order and logically grouped.

Here is a detailed description of the construction of the alias, so that readers can modify it to suit their own needs. The alias has five parts connected by four pipes. To reassemble the alias, put the five parts on a single line and add it to your .cshrc file.

As a summary, here's how it works. If one types:
 $ spot xanadu 
mdfind is asked to find all files in the current directory containing xanadu in their metadata. The output is piped to ls -lt, to sort it into chronological order (most recent at the top). The result of this is then piped to sed for tidying. Read on for the details...
read more (284 words)   Post a comment  •  Comments (9)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[9,401 views] Email Article To a Friend View Printable Version
Find duplicate Address Book entries via a script UNIX
I was looking for an AppleScript that would just show me the duplicate entries in my Address Book, and not delete them out of hand, since some have different information yet the same name. I could not find one, but found this great gem from Apple Developer Documentation - Apple Script:
osascript -e 'tell app "Address Book" to get the name of every person' \
| perl -pe 's/, /\n/g' | sort | uniq -d
It will give you a nice listing of every duplicate entry in the Address Book, making it easier to sort through them for information and delete them individually.

[robg adds: Address Book's Card: Look for Duplicate Entries feature doesn't provide much information at all prior to merging -- it will just say "one duplicate card was found; do you want to merge this data?," without telling you which cards are duplicates. This script will let you verify which cards may be merged, prior to doing so. Note that the script is based simply on name matches, so you may see more duplicates listed via its ouput than you would with Address Book's duplicate feature.]
  Post a comment  •  Comments (18)  
  • Currently 4.17 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[33,520 views] Email Article To a Friend View Printable Version
10.4: A collection of 'Spotlight from Terminal' tips UNIX
Tiger only hintI just wrote a detailed article on using Spotlight from the Terminal. Here are a few tips from that article:

Example 1. A Basic Spotlight Query

The commandline version of Spotlight is mdfind. Simply provide your search query as a parameter and let it run.

evil:~/Desktop mohit$ mdfind Rails
/Users/mohit/Documents/Rails4Days.pdf
/Users/mohit/Documents/Agile Development with Rails.pdf
/Users/mohit/Library/Mail/POP-foobar@mail.snip.com/INBOX.mbox/Messages/20455.emlx
/Users/mohit/Local/rails
/opt/local/lib/ruby/gems/1.8/cache/rails-1.0.0.gem
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/bin/rails
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/builtin/controllers/rails_info_controller.rb
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/html/index.html
/opt/local/lib/ruby/gems/1.8/gems/rails-1.0.0/html/images/rails.png

The files that are listed also include files with content and metadata that matches the query expression.
read more (113 words)   Post a comment  •  Comments (5)  
  • Currently 3.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[14,070 views] Email Article To a Friend View Printable Version
A network interface status script for GeekTool UNIX
I love GeekTool and use it all over my desktop. So I thought that I'd share the script that I use to keep the status of my network interfaces on my desktop at all times. Please pardon the fact that it's written in csh, but I'm a long-time SunOS user, and that's what I use for most of my quick and dirty stuff.

Here's the code:


#! /bin/csh
# 2006 Beerguy's Reef - www.hopdog.com
#

foreach if(`ifconfig -a | grep ^en | awk '-F:' '{print $1}'`)

/sbin/ifconfig $if > /tmp/if-stat

set addr = `cat /tmp/if-stat | grep 'inet ' | awk '-F ' '{print $2}'`
set speed = `cat /tmp/if-stat | grep media | awk '-F: ' '{print $2" "$3}'| head -1`

echo $if": "$addr $speed
rm /tmp/if-stat
end

If you'd just like to download the script, you can grab it here. You can call it as a script from GeekTool, or just run it in a Terminal. The output looks like this:
en0: 10.0.1.11 autoselect (100baseTX <full-duplex>) status active
en2:  <unknown type> status inactive
[robg adds: This works as described...]
  Post a comment  •  Comments (4)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[16,902 views] Email Article To a Friend View Printable Version