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

10.4: Add readline support to Tiger's python UNIX
For licensing reasons, Python on OS X comes without readline support (libreadline is GPL). Unfortunatley, this earlier hint no longer works in Tiger.

There is, however, a standalone readline distutils package made by Bill Bumgarner. I have slightly adapted it [click to download] to work either with a pre-installed readline from Fink, or with the included readline-5.1 without installing it. Hope this helps!

[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (4)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[13,862 views] Email Article To a Friend View Printable Version
10.4: Trigger backups on connect with launchd UNIX
I have been searching for some sort of automated backup while I wait patiently for 10.5's Time Machine. While searching, I found this article on TUAW covering one method of automating the process.

I have re-written the backup scripts from that article to make them a little friendlier. Current features include:
  • Supports the backing up of multiple source directories
  • Uses rsync to cut down on un-necessary file transfers
  • Designed to allow for a minimum time between backups (default 24 hours) to prevent un-necessary system interruption.
I am planning on implementing several new features when time permits, including different backup profiles for different devices (eg: full backup to this drive, but only backup my documents and keychain when my iPod is plugged in...), and network rsync support...

Full code and instructions can be found here, and comments and suggestions welcome...

[robg adds: I haven't tested this one, but since backup is a personal hot topic of mine (not enough people have working (ideally multiple) backups), I thought it worth sharing.]
  Post a comment  •  Comments (9)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[18,803 views] Email Article To a Friend View Printable Version
Describe all Unix apps in current PATH UNIX
Previous hints have mentioned that you can get a list of Unix-level commands in the Terminal via auto-completion features of the shell, and that you can get a one-line synopsis of a specified Unix command with the whatis command -- and that this can be used to search for a desired command.

The hint presents a way to generate a list of all of the Unix commands in your execution PATH (see this Unix FAQ for an explanation of the execution PATH variable) with a one-line synopsis for each program (assuming this one-line description is available). This is accomplished via a rather complicated pipeline of commands:

echo $PATH | sed -e 's/:/ /g' | xargs -J % find % -maxdepth 1 \( -type f -or -type l \) | xargs basename | sort | uniq | xargs whatis 2> /dev/null | grep -E '\((1|1m|6|8)\)' | perl -ne '($name, $descrip) = m/^(.*?)\s+- (.*)$/; $name =~ s/\((1|1m|6|8)\)//g; printf("%-20s - %s\n", $name, $descrip)'

Here are the first several lines of output from the above command when run on my Mac:
SystemStarter    - Start, stop, and restart system services
Xmark            - summarize x11perf results
Xnest            - a nested X server
Xquartz          - X window system server for Quartz operating system
Xvfb             - virtual framebuffer X server for X Version 11
a2p              - Awk to Perl translator
...
If you want the output of the above command to be saved into a file instead of appearing in the Terminal window, add a greater-than sign and then the name of the file you want to create at the end of the command.
read more (905 words)   Post a comment  •  Comments (14)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[11,692 views] Email Article To a Friend View Printable Version
A simple MacPorts and Fink update script UNIX
If you use the MacPorts and Fink package managers, you might find it useful to be able to update both package managers with one simple command. I wrote the following simple script which does just that:
#!/bin/bash
#the script updates MacPorts and Fink packages;

if [ "$(whoami)" != 'root' ]; then
  echo "You have no permission to run $0 as non-root user."
  exit 1
fi

port selfupdate
port -d sync
portindex
port upgrade installed
apt-get update
apt-get upgrade
fink -q -y selfupdate
fink -q -y update-all
Just create a file containing that code and save it, say, to your home folder. Assuming that the file's been saved as ~you/updf (where you is your short username), just cd to that directory and make the code executable:
chmod u+x upfg
If it's not already set, you might also add the line PATH=$PATH:~you to your profile. Then simply type sudo upfd, wait a little bit, and you're done. Hopefully, that is, if there are no compilation errors, but that's another story!
  Post a comment  •  Comments (5)  
  • Currently 3.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[25,091 views] Email Article To a Friend View Printable Version
Create an HTML page from Safari's bookmarks UNIX
I was trying to figure out a way to be able to access my my Safari bookmarks from anywhere, without having to dig through the plist folder over ssh (especially on a slow connection). So, I wrote a shell script to do it; it does require plcat, which is part of the free PLtools package.

[robg adds: Set the script to executable (chmod a+x script_name), and edit the script to replace **YOUR USERNAME** with, well, your user name. I tested the script, and it works -- it creates an index.html file in whichever directory you run it in. You can then edit or view the index.html file using any text editor, such as vi.]
  Post a comment  •  Comments (11)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[15,133 views] Email Article To a Friend View Printable Version
An easy install of the ffmpeg command line tool UNIX
I always wanted to use the ffmpeg command line tool (the one ffmpegX is the GUI of) in Terminal, but I didn't find it in Fink, and I didn't want to compile it from an experimental source. Well, there is a working binary of ffmpeg bundled with ffmpegX. To get it, simply follow these steps:
  1. Get ffmpegX from the above URL. It's a pretty useful tool, because the ffmpeg synatx isn't quite easy to handle.
  2. Control-click on the ffmpegX application, choose Show Package Contents from the pop-up menu, and navigate into Resources.
  3. Copy ffmpeg to /usr/local/bin.
  4. Execute the following in Terminal (as admin):
    sudo chown root:wheel /usr/local/bin/ffmpeg
    sudo chmod 755 /usr/local/bin/ffmpeg
Now you have a working version of ffmpeg in the Terminal.

[robg adds: There may be other ways to get the binary as well, but this one seems quite simple.]
  Post a comment  •  Comments (10)  
  • Currently 3.29 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[89,303 views] Email Article To a Friend View Printable Version
Drag to save Mail attachments in Terminal UNIX
When you get an attachment in Mail, the usual way to move it to a folder is via the Save button in the message or a control-click and then choose Save (or you can drag it into a Finder window). Either of these methods brings up a Finder window from which you can mouse around to put it where you want.

But if you are already working in a Terminal window in the directory where you want to save the attachment, type 'cp ' (note the space), then drag the attachment to the Terminal window and drop it there. Finally, type a period. When you're done, your Terminal window will look something like this:
cp /private/var/tmp/folders.501/TemporaryItems
/com.apple.mail.drag-T0x40a280.tmp.1L2mdM/filename.txt .
Press Return and, voila!, your attachment is copied.

[robg adds: I broke the Terminal line for a narrower display; there won't be a line break when you actually do it.]
  Post a comment  •  Comments (3)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,176 views] Email Article To a Friend View Printable Version
A simple shell script to run system maintenance tasks UNIX
I created this simple bash script to perform periodic maintenance. I put the script file in my ~/bin directory, and I added the folliwing line to my .profile file (where my_user is my short username):
  export PATH=$PATH:/Users/my_user/bin
Now, when I want to perform maintenance, I open a Terminal window and type maint at the prompt.

[robg adds: Remember to chmod 655 ~/bin/maint to make the code executable. We've had a number of hints here over the years dealing with the periodic maintenance scripts. There are also numerous utility apps that will do this for you as well.]
  Post a comment  •  Comments (14)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[17,731 views] Email Article To a Friend View Printable Version
10.4: Compile Intel-native MyODBC drivers UNIX
If you're a web or FileMaker developer and need access to MySQL databases via ODBC, you probably know that there are no binary distributions of MyODBC drivers that work on an Intel Mac. The PowerPC version won't work, and just trying to compile from source won't either.

After discussions with others, we've succeeded in compiling myODBC and it works! The trick is that you need to make simple changes in three files. Change the references to odbcinst.h to iodbcinst.h in these files: util/MYODBCUtil.h, driver/myodbc3.h, and myodbcinst/myodbcinst.c.

A short article and video tutorial on the process can be found on our site.

[robg adds: Apparently this information is in a README.osx in the distribution, but many haven't found that (judging by the results of a quick net search). This thread on the macosxhints' forums also covers the problem; if you need more detail on the process, check either link.]
  Post a comment  •  Comments (4)  
  • Currently 1.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[6,037 views] Email Article To a Friend View Printable Version
A caution on using command-line zip for backups UNIX
This is a warning as well as a hint. Control-clicking on a file or folder brings up a contextual menu that includes the option to Create archive of "xxx". The created archive file is a zip file that can be unzipped with /usr/bin/unzip. So, one would think that OS X is using /usr/bin/zip to create the archive. But that isn't so. It seems that OS X creates the zip file using code internal to Finder. It seems (from output of ps or top) not to be using /usr/bin/zip. Now the warning: /usr/bin/zip is broken on HFS+ file systems. It is broken in two ways:
  1. By default, it does not preserve the resource fork of files that it archives.There seems to be no way to force it to preserve resource forks. (Has anyone found a way?)
  2. Its behaviour does not correspond to its man page: /usr/share/man/man1/zip.1
Those (like me) who want to automate backups of their system using command line tools should perhaps use /usr/bin/tar. The tar utility now (as of OS X 10.4.8 and perhaps earlier) preserves resource forks. It stores the resource fork of foo as ._foo, and then recombines the data and resource forks when untarring to an HFS+ volume. To archive and compress a folder foo and all of its subfolders, one can do:
$ /usr/bin/tar cjvf foo.tbz foo
And to restore it, one can do:
/usr/bin/tar xjvf foo.tbz
This seems to preserve the resource forks correctly. For other methods, maybe see the hint Easily create HFS-aware PKZIP and unix archives.
  Post a comment  •  Comments (22)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[27,219 views] Email Article To a Friend View Printable Version