<?xml version="1.0" encoding="utf-8"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>macosxhints.com Unix tips and tricks</title>
<link>http://www.macosxhints.com/index.php?topic=unix</link>
<description>Unix tips and tricks from macosxhints.com</description>
<managingEditor>webteam@macosxhints.com</managingEditor>
<webMaster>webteam@macosxhints.com</webMaster>
<copyright>Copyright 2009 Mac OS X Hints</copyright>
<generator>Geeklog</generator>
<pubDate>Fri, 20 Nov 2009 07:30:03 -0800</pubDate>
<language>en-gb</language>
<atom:link href="http://www.macosxhints.com/backend/hintsunix.rss" rel="self" type="application/rss+xml" />
<item>
<title>Back up OS X to a Windows machine on the network</title>
<link>http://www.macosxhints.com/article.php?story=20091110144030245</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091110144030245</guid>
<pubDate>Fri, 20 Nov 2009 07:30:02 -0800</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091110144030245#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I know there are plenty of back up/synchronization packages for the Mac, and I know Time Machine is awesome. But as I have a Linux/FreeBSD background, I wanted to do it my way. And none of the software I tried was able to do it my way :-). So the command line seemed to be a good solution.
&lt;br&gt;&lt;br&gt;
My office Windows machine has plenty of disk space on it, and it is rarely used. It was an ideal system (with not so ideal a file system) to do backups on. The solution I came up with requires:
&lt;ul&gt;
&lt;li&gt;A shared folder on the PC, mounted on the Mac.&lt;/li&gt;
&lt;li&gt;The Unix app &lt;tt&gt;rdiff-backup&lt;/tt&gt;, available via &lt;a href=&quot;http://www.macports.org&quot;&gt;MacPorts&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Notifications are sent using &lt;a href=&quot;http://growl.info/documentation/growlnotify.php&quot;&gt;growlnotify&lt;/a&gt;, part of the &lt;a href=&quot;http://growl.info/&quot;&gt;Growl&lt;/a&gt; notification system.&lt;/li&gt;
&lt;/ul&gt;
The final step was to write a custom shell script to back up my Mac to the mounted Windows shared folder; here's what that looks like:

 ...</description>
</item>
<item>
<title>Create a range of solid colors for Desktop backgrounds</title>
<link>http://www.macosxhints.com/article.php?story=20091101133818705</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091101133818705</guid>
<pubDate>Thu, 12 Nov 2009 07:30:00 -0800</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091101133818705#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Mac OS X Leopard and Snow Leopard come with a paltry set of solid colors for desktop backgrounds. This is easily remedied with the &lt;tt&gt;ImageMagick&lt;/tt&gt; package (available for install through both &lt;a href=&quot;http://www.macports.org&quot;&gt;MacPorts&lt;/a&gt; and &lt;a href=&quot;http://finkproject.org/&quot;&gt;Fink&lt;/a&gt;), and a quick Terminal command.
&lt;br&gt;&lt;br&gt;
The script below generates all the background images for web-safe colors that should then be immediately available for use in the Solid Colors section of the Desktop tab of the Desktop and Screen Saver System Preferences panel.

&lt;div style=&quot;margin-left: 20px; margin-top:10px; margin-bottom:10px; padding: 5px; border:1px solid; width:520px; overflow:scroll;white-space:nowrap;resize:both&quot;&gt;&lt;pre&gt;cd /Library/Desktop&amp;#92; Pictures/Solid&amp;#92; Colors; for r in 00 33 66 99 cc ff; do for g in 00 33 66 99 cc ff; do for b in 00 33 66 99 cc ff; do echo Creating image for color &amp;#36;r&amp;#36;g&amp;#36;b; convert -background &quot;#&amp;#36;r&amp;#36;g&amp;#36;b&quot; -page 256x256 text:- &quot;Background ...</description>
</item>
<item>
<title>10.6: Install fish shell on an upgraded version of 10.6</title>
<link>http://www.macosxhints.com/article.php?story=20091102085612743</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091102085612743</guid>
<pubDate>Thu, 12 Nov 2009 07:30:00 -0800</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091102085612743#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;img src=&quot;http://www.macosxhints.com/images/106only.png&quot; alt=&quot;Snow Leopard only hint&quot; align=&quot;left&quot; style=&quot;margin-right: 10px&quot;&gt;All the cool kids are using &lt;a href=&quot;http://fishshell.org/index.php&quot;&gt;fish&lt;/a&gt; (&lt;tt&gt;bash&lt;/tt&gt; is so 90's!), so why can't I? Because it won't install on my copy of Snow Leopard, dang it. I spent the greater part of this weekend trying to figure out why &lt;tt&gt;fish&lt;/tt&gt; didn't like me. Read this so you won't have to endure my pain.
&lt;br&gt;&lt;br&gt;
Using &lt;a href=&quot;http://www.macports.org&quot;&gt;MacPorts&lt;/a&gt;, typing &lt;tt&gt;port install fish&lt;/tt&gt; wouldn't result in a working installation. The install kept asking for &lt;tt&gt;iconv&lt;/tt&gt;, &lt;tt&gt;gettext&lt;/tt&gt;, or whatnot. 64-bit/32-bit Unix apps don't play well together in Snow Leopard, and because I upgraded from Leopard, I needed to reinstall MacPorts to deal with it. Long and painful, indeed.
&lt;ol&gt;
&lt;li&gt;Follow the directions on upgrading in &lt;a href=&quot;http://trac.macports.org/wiki/Migration&quot;&gt;this entry&lt;/a&gt; in the MacPorts wiki. The basic steps ar...</description>
</item>
<item>
<title>Swap Command and Alt/Option keys in Terminal.app</title>
<link>http://www.macosxhints.com/article.php?story=20091102130443178</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091102130443178</guid>
<pubDate>Thu, 12 Nov 2009 07:30:00 -0800</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091102130443178#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>The free program &lt;a href=&quot;http://github.com/aim-stuff/cmd-key-happy&quot;&gt;cmd-key-happy&lt;/a&gt; allows you to swap the Command and Alt/Option keys in any application, but in particular, in Terminal.app.
&lt;br&gt;&lt;br&gt;
This can be extremely handy when &lt;tt&gt;ssh&lt;/tt&gt;'ing into other UN*X boxes and running &lt;tt&gt;emacs -nw&lt;/tt&gt;. It also allows you to have the traditional readline navigation work properly when using Bash (i.e., alt-backspace, alt-f, alt-b, etc). See &lt;a href=&quot;http://andrewmcdermott.blogspot.com/2009_11_01_archive.html#3199997329939252956&quot;&gt;this blog post&lt;/a&gt; for more details.
&lt;br&gt;&lt;br&gt;
[&lt;b&gt;robg adds:&lt;/b&gt; Installation help is available in the &lt;a href=&quot;http://github.com/aim-stuff/cmd-key-happy/blob/master/INSTALL&quot;&gt;INSTALL file&lt;/a&gt; in the github repository. I haven't tested this one.]</description>
</item>
<item>
<title>Record CPU usage for a given process over time</title>
<link>http://www.macosxhints.com/article.php?story=2009102906322976</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=2009102906322976</guid>
<pubDate>Thu, 29 Oct 2009 07:30:05 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=2009102906322976#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;a href=&quot;http://twitpic.com/ncqpp/full&quot;&gt;&lt;img src=&quot;http://www.macosxhints.com/images/ffusage.png&quot; align=&quot;right&quot; style=&quot;padding-left:7px&quot;&gt;&lt;/a&gt;For an upcoming project involving virtualization applications, I wanted an easy way to record the CPU usage for a given program over time.
&lt;br&gt;&lt;br&gt;
I'm aware of the &lt;a href=&quot;http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html&quot;&gt;Instruments&lt;/a&gt; program included in the Xcode Developer Tools, but I was looking for something simple, that I could run without a lot of overhead, and that would just record data for further analysis in Excel. 
&lt;br&gt;&lt;br&gt;
After a bit of digging with Google, I didn't find anything that quite worked (a friend tells me that &lt;a href=&quot;http://oss.oetiker.ch/mrtg/&quot;&gt;mrtg&lt;/a&gt; and &lt;a href=&quot;http://www.cacti.net/&quot;&gt;Cacti&lt;/a&gt; should handle this; I haven't tried them yet), so I created a relatively simple &lt;tt&gt;bash&lt;/tt&gt; script to get the job done - special thanks...</description>
</item>
<item>
<title>Download all Apple open source OS X files at once</title>
<link>http://www.macosxhints.com/article.php?story=20091014194517371</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091014194517371</guid>
<pubDate>Thu, 29 Oct 2009 07:30:04 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091014194517371#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>While it is well known that Mac OS X contains open source code, how to access and download that source code is perhaps less well known. Apple publishes all its open source code on their &lt;a href=&quot;http://opensource.apple.com/&quot;&gt;Apple Open Source site&lt;/a&gt;. However, this site makes you download each program individually, without an obvious option to download an entire OS X release at once (i.e., all public sources for 10.6.1).
&lt;br&gt;&lt;br&gt;
So I wrote the following &lt;tt&gt;bash&lt;/tt&gt; script to automate the download procedure. It downloads the individual tarballs for each program, expands them locally, and then rolls everything up into one big tarball for local storage. Some caveats are that this script does not build the code, and that you are bound by a variety of licenses which are not included here (because no Apple code is included here).

 ...</description>
</item>
<item>
<title>10.6: See more process info in top</title>
<link>http://www.macosxhints.com/article.php?story=20091005044809617</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091005044809617</guid>
<pubDate>Wed, 21 Oct 2009 07:30:03 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091005044809617#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;img src=&quot;http://www.macosxhints.com/images/106only.png&quot; alt=&quot;Snow Leopard only hint&quot; align=&quot;left&quot; style=&quot;margin-right: 10px&quot;&gt;I am an old timer and use &lt;tt&gt;top&lt;/tt&gt; (instead of Activity Monitor) to keep an eye on my system.
&lt;br&gt;&lt;br&gt;
I just notice that in Snow Leopard when you horizontally resize the Terminal (or &lt;tt&gt;xterm&lt;/tt&gt;) window, &lt;tt&gt;top&lt;/tt&gt; displays more information about the running processes -- new columns are added as the window grows wider. Use &lt;tt&gt;man top&lt;/tt&gt; to get an explanation of what those extra columns display.
&lt;br&gt;&lt;br&gt;
Another nice change is that the Process ID (PID) is now suffixed with &lt;tt&gt;-&lt;/tt&gt; to indicate a 32-bit process, and a &lt;tt&gt;*&lt;/tt&gt; to indicate a PowerPC process.</description>
</item>
<item>
<title>Translate outgoing destination ports</title>
<link>http://www.macosxhints.com/article.php?story=20091003133927453</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20091003133927453</guid>
<pubDate>Wed, 21 Oct 2009 07:30:02 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20091003133927453#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>This is probably evident for Unix wizards, but I spent a whole morning figuring this out so I thought some of you might find it useful too.
&lt;br&gt;&lt;br&gt;
I have a client app which does not permit specifying a non-standard destination port. In this example, it is an LDAP client which will only contact a host on the local network on the standard port &lt;tt&gt;389&lt;/tt&gt;. The LDAP server it is trying to contact is in the local network at &lt;tt&gt;193.168.4.253&lt;/tt&gt;, but listening on the non-standard port &lt;tt&gt;712&lt;/tt&gt;. So, I had to set up a port translation for outgoing connections. The code to achieve this is as follows (must be run with &lt;tt&gt;sudo&lt;/tt&gt; privileges, or as root in a &lt;tt&gt;launchd&lt;/tt&gt; startup daemon to make it persistent):

&lt;pre&gt;&lt;code&gt;sysctl -w net.inet.ip.forwarding=1
ipfw add 01000 divert natd tcp from me to 192.168.4.253 389 via en0
ipfw add 01000 divert natd tcp from 192.168.4.253 712 to me via en0
cat &amp;gt; natd.conf &amp;lt;&amp;lt; end
interface en0
reverse
same_ports
redirect_port tcp 192.168...</description>
</item>
<item>
<title>Ease encrypt/decrypt via ssl with two functions</title>
<link>http://www.macosxhints.com/article.php?story=200909261758267</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=200909261758267</guid>
<pubDate>Thu, 15 Oct 2009 07:30:02 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=200909261758267#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>The following two functions (just add to your &lt;tt&gt;.bash_profile&lt;/tt&gt; or &lt;tt&gt;.profile&lt;/tt&gt; file) will make life easier when encrypting and decrypting files with &lt;tt&gt;openssl&lt;/tt&gt; in Terminal:

&lt;div style=&quot;margin-left: 20px; margin-top:10px; margin-bottom:10px; padding: 5px; border:1px solid; width:520px; height:120px; overflow:scroll;white-space:nowrap;resize:both&quot;&gt;&lt;pre&gt;&lt;code&gt;function encrypt {
  if &amp;#91; &quot;&amp;#36;1&quot; = &quot;&quot; &amp;#93;; then
    echo &quot;Usage: encrypt filename&quot;
  elif &amp;#91; -d &quot;&amp;#36;1&quot; &amp;#93;; then
    echo &quot;&quot;&amp;#36;1&quot; is a directory&quot;
  elif &amp;#91; -L &quot;&amp;#36;1&quot; &amp;#93;; then
    echo &quot;&quot;&amp;#36;1&quot; is a symbolic link&quot;
  elif ! &amp;#91; -r &quot;&amp;#36;1&quot; &amp;#93;; then
    echo &quot;&quot;&amp;#36;1&quot; is not readable&quot;
  else
    /usr/bin/openssl aes-256-cbc -salt -in &quot;&amp;#36;1&quot; -out &quot;&amp;#36;1&quot;.aes
      if &amp;#91; &amp;#36;? -eq 0 &amp;#93; ; then
        echo &quot;encryted file: &quot;&amp;#36;1&quot;.aes&quot;
      fi
  fi
}

function decrypt {
  if &amp;#91; &quot;&amp;#36;1&quot; = &quot;&quot; &amp;#93; || &amp;#91; &quot;&amp;#36;{1##*.}&quot; != aes &amp;#93;; then
    echo &quot;Usage: decrypt filename.a...</description>
</item>
<item>
<title>Handle resource forks correctly with newer rsync</title>
<link>http://www.macosxhints.com/article.php?story=20090926210822409</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090926210822409</guid>
<pubDate>Thu, 15 Oct 2009 07:30:01 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090926210822409#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>For &lt;a href=&quot;http://www.samba.org/rsync/&quot;&gt;rsync&lt;/a&gt; users, the newest version of &lt;tt&gt;rsync&lt;/tt&gt; (3.0.6 as of this moment) seems to be able to handle Mac extended attributes and resource forks correctly. Unfortunately, it doesn't seem to ship with Snow Leopard, but it can be downloaded and installed fairly easily.

After downloading from the above-linked site, just follow the instructions in the &lt;tt&gt;INSTALL&lt;/tt&gt; text file, and remember that the &lt;tt&gt;make install&lt;/tt&gt; command needs to be run with administrator privileges (&lt;tt&gt;sudo&lt;/tt&gt;). Further, you may need to adjust your &lt;tt&gt;PATH&lt;/tt&gt; and &lt;tt&gt;MANPATH&lt;/tt&gt; settings, so that &lt;tt&gt;/usr/local/bin&lt;/tt&gt; and &lt;tt&gt;/usr/local/share/man&lt;/tt&gt; (the default install locations) appear earlier in the list than do &lt;tt&gt;/usr/bin&lt;/tt&gt;, the home of the stock &lt;tt&gt;rsync&lt;/tt&gt;.
&lt;br&gt;&lt;br&gt;
Your current &lt;tt&gt;rsync&lt;/tt&gt; scripts may need some tweaking, too. For example, the &lt;tt&gt;-E&lt;/tt&gt; flag no longer refers to extended attributes (it now tells rsync to preserve exec...</description>
</item>
<item>
<title>10.6: Compress files with HFS+ compression</title>
<link>http://www.macosxhints.com/article.php?story=20090902223042255</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090902223042255</guid>
<pubDate>Thu, 17 Sep 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090902223042255#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;img src=&quot;http://www.macosxhints.com/images/106only.png&quot; align=&quot;left&quot; style=&quot;margin-right: 10px&quot;&gt;Snow Leopard introduces a new feature that has been used on most of the system files: HFS+ compression. This compression is rather different than most other file compression options available in the sense that it is completely transparent; there isn't even a way to tell that the files are compressed using Snow Leopard's included command line tools (in fact, contrary to what some posts on this site have suggested, command line utilities like &lt;tt&gt;strings&lt;/tt&gt; will see the same file regardless if it is compressed or not).
&lt;br&gt;&lt;br&gt;
In order to even determine if a file is compressed using HFS+ compression or not, a tool like &lt;a href=&quot;http://osxbook.com/software/hfsdebug/&quot;&gt;hfsdebug&lt;/a&gt; is needed.
As an example, here's part of the &lt;tt&gt;hfsdebug&lt;/tt&gt; output for the QuickTime X executable:

 ...</description>
</item>
<item>
<title>Adjust brightness from Terminal</title>
<link>http://www.macosxhints.com/article.php?story=20090901021817717</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090901021817717</guid>
<pubDate>Mon, 14 Sep 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090901021817717#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I've searched for a way to control the display brightness from the command line. I found several AppleScripts that open the System Preferences panel and set the slider, but I wanted a pure command line tool. Maybe someone else is looking for the same solution, so here is what I found:
&lt;br&gt;&lt;br&gt;
&lt;a href=&quot;http://mattdanger.net/2008/12/adjust-mac-os-x-display-brightness-from-the-terminal/&quot;&gt;This blog post&lt;/a&gt; discusses has a small commandline tool (written by &lt;a href=&quot;http://njr.sabi.net/&quot;&gt;Nicholas Riley&lt;/a&gt;) to set the brightness from Terminal. Just &lt;a href=&quot;http://mattdanger.net/portfolio/utilities/brightness.tar.gz&quot;&gt;download the binary [4KB]&lt;/a&gt; and install it. You can then set the brightness by typing &lt;tt&gt;brightness 0&lt;/tt&gt; (to set it to minimum, use &lt;tt&gt;1&lt;/tt&gt; for maximum, or any value between).
&lt;br&gt;&lt;br&gt;
&lt;em&gt;Note&lt;/em&gt;: The binary is Intel-Only (32-Bit), but the source code is available on the above linked page too, so you could easily compile a PowerPC or 64Bit Intel Binary on your o...</description>
</item>
<item>
<title>10.6 Server: Install HellaNZB without using MacPorts</title>
<link>http://www.macosxhints.com/article.php?story=20090830200012294</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090830200012294</guid>
<pubDate>Wed, 09 Sep 2009 07:30:02 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090830200012294#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;img src=&quot;http://www.macosxhints.com/images/106only.png&quot; align=&quot;left&quot; style=&quot;margin-right: 10px&quot;&gt;If you try to install &lt;a href=&quot;http://www.hellanzb.com/trac/&quot;&gt;hellanzb&lt;/a&gt; via &lt;a href=&quot;http://www.macports.org&quot;&gt;MacPorts&lt;/a&gt;, the method is currently broken on 10.6.. That's because &lt;tt&gt;py25-twisted&lt;/tt&gt; fails to build on my 64bit system (&lt;a href=&quot;https://trac.macports.org/ticket/20820&quot; title=&quot;Ticket #20820&quot; rel=&quot;nofollow&quot;&gt; Ticket #20820&lt;/a&gt;).
&lt;br&gt;&lt;br&gt;
The solution is to build using Python 2.5 instead of the default Python 2.6 in Snow Leopard. This avoids conflicts with Apple's own wiki and blog software, and problems with deprecated sys calls with HellaNZB.

&lt;ol&gt;
&lt;li&gt;Build Twisted-8.2.0 [&lt;a href=&quot;http://tmrc.mit.edu/mirror/twisted/Twisted/8.2/Twisted-8.2.0.tar.bz2#md5=c85f151999df3ecf04c49a781b4438d2&quot;&gt;download&lt;/a&gt;: &lt;tt&gt;sudo /usr/bin/python2.5 setup.py install&lt;/tt&gt;&lt;/li&gt;

&lt;li&gt;Build hellanzb-0.13 [ ...</description>
</item>
<item>
<title>10.6: Set default time zone for PHP in Snow Leopard</title>
<link>http://www.macosxhints.com/article.php?story=20090831101932728</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090831101932728</guid>
<pubDate>Tue, 08 Sep 2009 07:30:05 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090831101932728#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>&lt;img src=&quot;http://www.macosxhints.com/images/106only.png&quot; align=&quot;left&quot; style=&quot;margin-right: 10px&quot;&gt;It seems like the new PHP version in Snow Leopard wants you to explicitly set a default timezone when calculating stuff using the &lt;tt&gt;date()&lt;/tt&gt; function, and will warn you about this in your script's output.
&lt;br&gt;&lt;br&gt;
To set the date, look in &lt;tt&gt;/etc&lt;/tt&gt; and find &lt;tt&gt;php.ini.default&lt;/tt&gt;, open it up in your favorite editor (BBEdit work great, but &lt;tt&gt;sudo pico /etc/php.ini.default&lt;/tt&gt; works as well). Look for this line:

&lt;pre&gt;&lt;code&gt;date.timezone = &lt;/code&gt;&lt;/pre&gt;

Add your preferred timezone, like so: 

&lt;pre&gt;&lt;code&gt;date.timezone = &quot;Europe/Berlin&quot;&lt;/code&gt;&lt;/pre&gt;

Read &lt;a href=&quot;http://nl.php.net/manual/en/function.date-default-timezone-set.php&quot;&gt;this page&lt;/a&gt; in the PHP manual for supported zones and cities.
&lt;br&gt;&lt;br&gt;
After you're done with that, rename the file using &lt;tt&gt;sudo mv php.ini.default php.ini&lt;/tt&gt; and restart your computer to implement the time zone change.</description>
</item>
<item>
<title>Send Growl notifications to Macs from Linux boxes</title>
<link>http://www.macosxhints.com/article.php?story=20090812044415524</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090812044415524</guid>
<pubDate>Thu, 13 Aug 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090812044415524#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>There is a way of sending messages to &lt;a href=&quot;http://growl.info/&quot;&gt;Growl&lt;/a&gt; running on a Mac OS X machine from any Unix machine with the standard X11 tools. You do not need to install anything on the Unix machine, just use the &lt;tt&gt;xkbbell&lt;/tt&gt; command.
&lt;br&gt;&lt;br&gt;
In short, you need to first install &lt;a href=&quot;http://growl.info/extras.php#growlnotify&quot;&gt;&lt;tt&gt;growlnotify&lt;/tt&gt;&lt;/a&gt; on the Mac. You then need a configuration file, &lt;tt&gt;xkbevd.cf&lt;/tt&gt;, with the following content:

&lt;pre&gt;&lt;code&gt;Bell()  shell &quot;/usr/local/bin/growlnotify --message &amp;#92;&quot;&amp;#36;(name)&amp;#92;&quot; --appIcon X11; true &quot;&lt;/code&gt;&lt;/pre&gt;

Start the X11 server, then start the &lt;tt&gt;xkbevd&lt;/tt&gt; daemon (again on the Mac) pointing to the configuration file you just created (&lt;tt&gt;xkbevd -cfg xkbevd.cf -bg&lt;/tt&gt;). You can then call the command &lt;tt&gt;xkbbell&lt;/tt&gt; on the Unix machine to generate a Growl notification on the Mac. For example, &lt;tt&gt;xkbbell &quot;lasers offline&quot;&lt;/tt&gt;. There are &lt;a href=&quot;http://wiesmann.codiferes.net/wordpress/?p=4536&quot;&gt;detai...</description>
</item>
<item>
<title>Keep Safari/Mail RSS feeds in sync between two Macs</title>
<link>http://www.macosxhints.com/article.php?story=20090804124508822</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090804124508822</guid>
<pubDate>Wed, 05 Aug 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090804124508822#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I have two Macs, a desktop and a portable, and on both I use Safari as an RSS reader. Until recently, I was having trouble keeping feeds synchronized. Obviously, after reading a set of feeds on one machine, I don't want to see them unread when I switch to the other one. I'm well aware that this problem can be solved by subscribing to MobileMe, Google Reader, or other &quot;cloud data&quot; services. I choose not to use them because of privacy concerns, which I'm not going to debate here. So I came up with a simple standalone method to sync my RSS data.
&lt;br&gt;&lt;br&gt;
My research showed that Safari stores information about RSS feeds in an SQLite database file called &lt;em&gt;Database.sqlite3&lt;/em&gt; in your home directory. That database is managed by a background process called PubSubAgent, which starts automatically when you log in. This process communicates with MobileMe, if you have an account, to sync the database between devices. I assume this is done by sending SQL commands over the network. Safari an...</description>
</item>
<item>
<title>Install Ruby 1.9 alongside Ruby 1.8</title>
<link>http://www.macosxhints.com/article.php?story=20090731080242407</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090731080242407</guid>
<pubDate>Tue, 04 Aug 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090731080242407#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>I have put together a process that will &lt;tt&gt;make&lt;/tt&gt; Ruby 1.9 from source, and install the resulting binaries in the folder of  your choice. The script downloads all the files and patches to &lt;tt&gt;/tmp&lt;/tt&gt;. I also wrote a script that allows me to swap  ruby 1.8 and 1.9 as I need. 
&lt;br&gt;&lt;br&gt;
Here's how I installed the newer version of Ruby in its own directory. First, I downloaded, compiled, and installed &lt;tt&gt;readline&lt;/tt&gt; and &lt;tt&gt;patch&lt;/tt&gt;:

&lt;pre&gt;&lt;code&gt;&amp;#36; cd /tmp
&amp;#36; curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
&amp;#36; tar xzvf readline-5.2.tar.gz
&amp;#36; cd readline-5.2
&amp;#36; curl -O http://ftp.gnu.org/gnu/readline/readline-5.2-patches/readline52-012
&amp;#36; patch -p0 &amp;lt;&amp;gt;
&amp;#36; ./configure --prefix=&amp;#36;HOME/
&amp;#36; make
&amp;#36; sudo make install
&amp;#36; cd ..&lt;/code&gt;&lt;/pre&gt;

Next, I downloaded, compiled, and installed the latest version of Ruby, picking up right where the above commands left off (comments denoted with &lt;tt&gt;#&lt;/tt&gt;):

 ...</description>
</item>
<item>
<title>Preserve photo timestamp when exporting from iPhoto</title>
<link>http://www.macosxhints.com/article.php?story=20090728095658110</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090728095658110</guid>
<pubDate>Thu, 30 Jul 2009 07:30:03 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090728095658110#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>When photos are exported from iPhoto using the Export function, all the photos will get the current date/time stamp. But if you use any of these photos in an app that organizes them by date/time, then the organization will be lost. For example, I export a set of images from iPhoto to view in my Wii's photo tool, but those images are organized by date.
&lt;br&gt;&lt;br&gt;
To fix this problem, I took advantage of the EXIF data in the JPEG images from my digital camera. To batch change a large set of images, I use the open source command-line tool &lt;tt&gt;jhead&lt;/tt&gt;, which is &lt;a href=&quot;http://www.sentex.net/~mwandel/jhead/&quot;&gt;available as a pre-compiled Intel binary&lt;/a&gt; (source code is also available from the website, or via &lt;a href=&quot;http://finkproject.org/&quot;&gt;Fink&lt;/a&gt;).
&lt;br&gt;&lt;br&gt;
I copied the &lt;tt&gt;jhead&lt;/tt&gt; binary into an Applications folder in my home directory, and made it executable with the following command:

&lt;pre&gt;&lt;code&gt;chmod 750 jhead&lt;/code&gt;&lt;/pre&gt;

Then I wrote a simple shell script to batch update ...</description>
</item>
<item>
<title>Copy timestamps between a file or multiple files</title>
<link>http://www.macosxhints.com/article.php?story=2009071909120699</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=2009071909120699</guid>
<pubDate>Tue, 28 Jul 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=2009071909120699#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>Sometimes I find the need to copy a file's timestamp to another file. For example, when I do batch conversion of video files (e.g. via VisualHub), the converted files' timestamps are all based on the current date. Subsequently when I import them in iMovie, I have to spend some effort to get them to show the correct date. It would be nicer if the converted files' timestamps were exactly the same as the original ones.
&lt;br&gt;&lt;br&gt;
So I created this shell script, which allows you to copy the timestamp from one file to another.

&lt;div style=&quot;margin-left: 20px; margin-top:10px; margin-bottom:10px; padding: 5px; border:1px solid; width:520px; height:120px; overflow:scroll;white-space:nowrap;resize:both&quot;&gt;&lt;pre&gt;&lt;code&gt;#!/bin/bash

if &amp;#91; &amp;#36;# -ne 2 &amp;#93;; then
  echo &quot;Usage: `basename &amp;#36;0` timestamp_src dest_file&quot;;
  exit 1;
fi

function printtimestamp()
{
  stat -n -f &quot;%Sm&quot; -t &quot;%Y%m%d%H%M&quot; &quot;&amp;#36;1&quot;
}

SRC=&amp;#36;1
DST=&amp;#36;2

if &amp;#91; ! -f &quot;&amp;#36;{SRC}&quot; &amp;#93;; then
  echo &quot;Error: &amp;#36;{SRC} d...</description>
</item>
<item>
<title>xargs and working with spaces in filenames</title>
<link>http://www.macosxhints.com/article.php?story=20090710062214206</link>
<guid isPermaLink="true">http://www.macosxhints.com/article.php?story=20090710062214206</guid>
<pubDate>Tue, 21 Jul 2009 07:30:00 -0700</pubDate>
<comments>http://www.macosxhints.com/article.php?story=20090710062214206#comments</comments>
<dc:subject>UNIX</dc:subject>
<description>When I'm working on a project I don't know much about, I do this before I do the compiles, so that the file &lt;tt&gt;FILES&lt;/tt&gt; only has the source code: 

&lt;pre&gt;&lt;code&gt;find . -type f -print &amp;gt; FILES&lt;/code&gt;&lt;/pre&gt;

Then, on most Unix platforms, I can do something like this with &lt;tt&gt;FILES&lt;/tt&gt;:

&lt;pre&gt;&lt;code&gt;xargs egrep whatever &amp;lt; FILES&lt;/code&gt;&lt;/pre&gt;

On the Mac, however, this often breaks because of spaces in file names. I know about the &lt;tt&gt;-print0&lt;/tt&gt; option in &lt;tt&gt;find&lt;/tt&gt;, so I could have two files, &lt;tt&gt;FILES&lt;/tt&gt; and perhaps &lt;tt&gt;FILES0&lt;/tt&gt;, which I could produce with:

&lt;pre&gt;&lt;code&gt;find . -type f -print0 &amp;gt; FILES0&lt;/code&gt;&lt;/pre&gt;

I could then follow that with this:

&lt;pre&gt;&lt;code&gt;xargs -0 egrep whatever &amp;lt; FILES0&lt;/code&gt;&lt;/pre&gt;

But I just figured out another solution...
I can do this in one step like this:

&lt;pre&gt;&lt;code&gt;tr '&amp;#92;n' '&amp;#92;0' &amp;lt; FILES | xargs -0 egrep whatever&lt;/code&gt;&lt;/pre&gt;

And, this could be plopped into a script like:

&lt;pre&gt;&lt;code&gt;#!/bin/sh

tr '&amp;#92;n' '&amp;#92;0' | xarg...</description>
</item>
</channel>
</rss>
