Here are some tips for getting the PHP pecl_http extension running on a Macintosh OS X 10.5.x Leopard 64-bit Intel machine. For starters, you need to follow the instructions in the PHP Documentation pages to install the PEAR/PECL manager, because it is no longer in the standard OS X setup:
To compile the extension, you have to install the Developers (Xcode) from your system disks because they are not installed by default. This is a simple step.
It's not made clear that you need to install an older version of pecl_http than the latest stable version (1.6.1 as of this writing), because 1.6.1 needs PHP6. I used version 1.5.6 successfully. So, your Terminal command has to be sudo pecl install pecl_http-1.5.6.
There is apparently a libcurl dependency in the case of pecl_http (although no dependencies are listed at the extension site), but it came with the excellent entropy.ch PHP installation I substituted for the bundled PHP installation. I needed the entropy.ch version because it has the PDO_MYSQL extension and driver I need for the Zend Framework.
Note that using the entropy.ch substitute can confuse the PECL install manager (it may place the compiled extension in the wrong place for the substitute) -- it's easy enough to move (mv) it after it's successfully compiled.
Once compiled and located properly, you may need to chmod the rights for the extension. I had to to make it comparable to the others in the extensions directory -- not sure this was strictly necessary, but I thought it would help to have them similarly owned and permitted.
As is made clear elsewhere, you need to add the following to your php.ini where all other extensions to load are listed: extension=http.so. I did not comment out the extension_dir="./" line as some suggest, and I had no problems.
Last and perhaps most important, I had to change the underlying Apache startup plist file so that it comes up in 32-bit mode -- it never worked under the standard 64-bit mode.
Read the rest of the hint for the details on the required change to the Apache file noted in the last item above...
I run a number of web apps here in the house -- a copy of the macosxhints.com site, for instance, where I can experiment with changes before making them on the live site. I recently got rid of the machine I was using to host these sites, and migrated everything over to the Mac Pro. As part of that process, I had to install MySQL, which is basically a very simple operation. Just download the proper package from their downloads page, and run the installer.
When I did this, though, I didn't notice that the default download is MySQL version 5; for compatibility reasons, I actually wanted MySQL 4.1. Unfortunately, I got all the way through the install before I noticed that I had installed version 5. So I removed the MySQL 5 files in /usr/local, downloaded the 4.1 version, and ran its installer. Unfortunately, the installer told me I couldn't install 4.1, as I already had a newer version of MySQL on the machine -- even though I'd just deleted it.
After a bit of digging, I found the cause and the solution. The MySQL installer checks for the existence of other MySQL versions by looking in the /Library/Receipts folder, not by looking for an actual installed version of MySQL. So I deleted the MySQL receipts folder I found in /Library/Receipts (it was named something like mysql-standard-5.0.67-apple-darwin8.5.1-i686.pkg), then ran the 4.1 installer again. This time, MySQL installed without any problems, and my locally-hosted sites are up and running again.
OS X 10.5 includes a command line audio player (in /usr/bin) called afplay. This is very useful if you want to play a sound file from the command line, shell script, Automator action, etc. The /usr/bin directory is in your path by default, so you can just type afplay file.mp3 to play that file.
afplay makes use of Core Audio, so I think it can play any audio file that QuickTime supports (including mp3, aiff, wav, etc.). If any one is interested, Apple also provides the source code for this application with the Xcode developer tools. You'll find it in this folder: /Developer » Examples » CoreAudio » Services » AudioFileTools.
[robg adds: There's a very simple man page for afplay, which then tells you that help is available with afplay -h. There are a few interesting options, including the ability to play a defined (in time) segment of a file, and to play a file to a defined audio output device.]
OS X uses a disappointingly convoluted set of programs and preferences to send a fax. Trying to debug why a particular fax isn't getting through to a particular machine is frustrating, since Apple doesn't provide any help at all. If you happen to stumble upon it, you may see the CUPS log file in /var/log/cups/error_log, which may contain error messages about your failed fax. You can also see this file by opening the log from the fax printer queue (if you made one).
I've found that the Apple OS X fax formats aren't particularly compatible with a number of other fax recipients -- I sometimes get repeated errors in /var/log/cups/error_log that look like this:
E [date time] [Job 53] There was a fax protocol error.
E [date time] PID 352 (/usr/libexec/cups/backend/fax) stopped with status 1!
I [date time] Hint: Try setting the LogLevel to "debug" to find out more.
But that leaves you wondering "how do I set LogLevel to debug?"
I had the need for a simple backup solution for disk-to-disk backups on servers. I wanted it to be administered through a terminal (via ssh), run in the background without user interaction, and email me a report once it did its work. I also wanted it to autorotate my backups, and to use hardlinks to save space and speed up incremental backups. Since I couldn't find something simple that suited my needs, I wrote mlbackup.
mlbackup is a convenient wrapper around rsync 3, which is included in the download. rsync 3 itself is compiled as an universal binary, optimized for PPC and Intel processors in 32-bit and 64-bit incarnations.
There are a ton of features in mlbackup; beyond the autorotation, use of hard links, and email notification noted above, it also includes easy configuration via a text file, backs up all HFS+ metadata, skips certain OS X files (caches, temp files) that don't need to be backed up, and postpones Spotlight indexing until the backup is completed. It can also be used to remotely pull backups with rsync ssh transport. (This requires ssh hostkey authentication to be set up for automated backups.) For this to work, mlbackup needs to be installed on both source and destination Macs, and having the same version installed across Macs is highly recommended!
mlbackup is available for free under the GPLv3, and all sources are included with the download. Bugreports and feedback for mlbackup are welcome; the email address can be found in the README file included in the download. Backups created with mlbackup pass the backup tests in the Backup-Bouncer test suite.
[robg adds: I found this worth mentioning because I've basically cobbled together a series of scripts that do similar things, but each one needs to be customized for the backup task at hand, and I know I don't copy all the proper HFS+ metadata. While I haven't tested mlbackup yet, I intend to -- and given that it's free and open source, I thought others might be interested as well. I have mirrored the r88 download (2MB) here on Mac OS X Hints, in case the original server isn't available at some point in the future. You should check the author's site first for the latest version, however.]
Suppose You want to write a Perl script that takes advantage of Keychain Access as a place to read settings from. It can be done. But what about manipulating those Keychain data? AppleScript can do that. As a generic example, "MyProgram" uses Keychain for:
storing service name for MyProgram (which is actually the real identity for the program, while the system call security uses -s as an argument)
username for MyProgram
password for MyProgram
URI for MyProgram
runstate for MyProgram
The corresponding Keychain Access key fields would be:
Name for RUNSTATE
Account for PROGRAMID
Where for SERVICENAME
Comments for PROGRAMURI
Password for PROGRAMPW
Read on for the AppleScript part for MyProgram, where you set up the field values, start or stop the program, etc. -- kind of the GUI side of the program -- as well as additional AppleScript and perl examples.
[robg adds: This is a long, detailed hint that was first posted on the author's blog. I'm recreating it here in case the original ever vanishes. You can read the fully entry here or on the author's blog.]
When you upgrade to OS X 10.5.5, remote X viewing (via X11) gets disabled. This is fine for most people, however for those of us who use remote apps, it's a pain. The following defaults setting will take care of the issue. In Terminal, issue this command:
I noticed a new post on a very old thread on the Mac OS X Hints forums site, which was about being able to start a sync to .Mac (MobileMe) from the command line. The new post showed how to use an AppleScript to control the MobileMe preferences pane and then click the Sync Now button.
While this may work, I suspected that there must be a better way, and so I had a dig around. I found dotmacsyncclient, located in /System » Library » PrivateFrameworks » DotMacSyncManager.framework » Versions » A » Resources. Further investigation showed that, indeed, you can start a sync from the command line -- and much more.
Note that the following examples assume you have cd'ed into the above directory first...
I worked in a school district for a few years where we had two break-ins that included thefts of Mac laptops. So I decided to create something that would help track laptops in the event they were stolen. This is of course free, one of its major advantages. It is also hosted by yourself, so it is easy to control. This has run on about 1,500 computers without causing any type of overload on machines or the network, and it does exactly what it is suppose to do. I now use it on all home and family computers because I trust it so well. I have used it for about a half a year and it works on Tiger and Leopard.
Note that this is software, so if the thief erases the hard drive on the computer, this will remove the phoning home capabilities. This does take some tinkering around, so it's fairly advanced. But the end result is very rewarding. This hint is broken up into the following sections -- be sure not to skip anything:
To back up a local UNIX serving box (ALIX1C motherboard with FreeBSD), I wrote a simple but efficient bash script to save all or part of it in a DMG image disk file. This backup should be used as often as required (launching with cron needs a password-free RSA login). This backup is a differential one, and an exact replication is done assuming the RSA user has sufficient privileges to do so.
Why save in a DMG?
To avoid my Mac managing another file system deep tree.
To simplify moving the backup.
I'm aware I'm losing Time Machine benefits with such a solution, but the script is very easy to modify to sync to a simple file system local folder. Personnaly, my DMG is placed on my Time Machine disk, to avoid filtering the Apple Backup system.
For security and convenience, I use ssh transfering protocol with a shared RSA key. If you do not know how to set this up, you should look at that kind of search. Both boxes (the remote and the Mac) need rsync binaries. On the Mac, you'll need a DMG that's as large as the remote system to back up to. Its name and its mounted name are supposed to be the same.