Peter’s Mac OS X Notes

Peter’s Mac OS X Notes

This is a list of various unix projects I've installed under Mac OS X and any issues I have in making them work.

Contents

Environment Variables

Under Mac OS X, environment variables can be configured in three different places, and each one makes the variables available to different things:

~/.MacOSX/environment.plist

This file is read in when you log in as a user under Mac OS X. All the variables are made available to any application or process you launch, which probably includes the Terminal and hence any shells you open directly. In particular, this would include applications like BBEdit and CodeWarrior which runs scripts (like perl and cvs) on your behalf.

This file is a plist and can be edited with the property editor, or manually, or it can be created magically from your existing environment via a script.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
        <key>CVSROOT</key>
        <string>yourusername@yourhost:/cvs</string>
        <key>CVS_RSH</key>
        <string>ssh</string>
        <key>DISPLAY</key>
        <string>localhost</string>
        <key>LC_ALL</key>
        <string>C</string>
        <key>PERL5LIB</key>
        <string>/Library/Perl:/Users/yourusername/perl</string>
</dict>
</plist>

Changes take effect at login, so you'll need to logout and log back in.

~/.cshrc or ~/.tcshrc

These files (only ever have one), are used by any tcsh shell you launch, including remotely accessed ones. Terminal launched ones probably pick up the environment.plist variables, but if you ssh into your Mac from another Mac, then probably not.

setenv PERL5LIB /Library/Perl:/Users/yourusername/perl
setenv CVSROOT yourusername@yourhost:/cvs
setenv CVS_RSH ssh
setenv LC_ALL C

crontab file

When you add cron jobs (using conrtab -e), they are neither run under your Mac OS X login nor under a tcsh shell, so you can also set envrionment variables in your crontab which will get used when executing cron actions.

PERL5LIB=/Library/Perl:/Users/yourusername/perl
LC_ALL=C
12 1 * * * perl dosomething.pl

exim

exim is a mail server with some very nice features.

exim-comp

This is a little Perl script I wrote to compile simple expressions into exim expressions. Hopefully it'll be useful to someone. here are some examples:

if $message_age < 300 then 1 else 0

Result: ${if <{$message_age}{300}{1}{0}}


if    !def('sender_host_address')  then 0 else 1

Result: ${if !def:sender_host_address{0}{1}}


if    $header('X-Stairways-Local') eq 'yes'  then 0 else 1

Result: ${if eq{$header_X-Stairways-Local:}{yes}{0}{1}}

if (($message_age < 300) & (exists('/var/lock/MASTER'))) |
(!defheader('X-delayed') & !(exists('/var/lock/MASTER'))) then 1 else 0

Result: ${if or {{and {{<{$message_age}{300}}{exists{/var/lock/MASTER}}}}
   {and {{!def:header_X-delayed:}{!exists{/var/lock/MASTER}}}}}{1}{0}}


if    !def('sender_host_address') 
     | ($sender_host_address eq "127.0.0.1") 
     | ($lc($header('X-Stairways-Local')) eq 'yes') then 0 else 1

Result: ${if or {{!def:sender_host_address}{eq{$sender_host_address}{127.0.0.1}}
   {eq{${lc:$header_X-Stairways-Local:}}{yes}}}{0}{1}}

Notes:

Caveats:

Not much testing (all the above run through exim -be, but whether they are correct I could not say!).

No documentation.

Available from here.