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

Enabling PHP to use sendmail UNIX
Having trouble with PHP and sendmail on your OSX install? Here's a little help from macos-x-server list:

In the /etc/mail/ file, add the line
 O DontBlameSendmail=GroupWritableDirPathSafe
right after the line
 #O DontBlameSendmail=safe
and this should allow PHP to send mail out through sendmail.

[Editor's note: I have not tried this myself...]
  Post a comment  •  Comments (9)  
  • Currently 2.00 / 5
  You rated: 3 / 5 (4 votes cast)
[8,371 views]  View Printable Version
Create a simple command-line mailchecker UNIX
What I really was missing on OS X so far was a small mailchecker. There are several programs for mail checking, but each one I tried takes almost as much RAM as, which I use. So I wrote a little script, run by cron, which checks whether there are new mails (using fetchmail) and fires up if there are.

Read the rest of the article for the script and installation instructions.
read more (489 words)   Post a comment  •  Comments (5)  
  • Currently 4.00 / 5
  You rated: 4 / 5 (3 votes cast)
[5,026 views]  View Printable Version
Manage multiple commands in one Terminal window UNIX
The powerful command-line 'screen' utility (see this hint for help installing screen) can handle multiple "windows" within the same screen session. It's quite like tabbed browsing in Mozilla or the way kterm works in KDE.

To create a new window you press "Ctrl-A c". To cycle forward through the list of windows use "Ctrl-A n"; backward is "Ctrl-A p", and "Ctrl-D" to terminate the screen. Assuming you have 'screen' installed, here's a quick example:
 % screen top
[Ctrl-A c]

% screen man tcsh
[Ctrl-A c]

% man screen
[Ctrl-A n] [Ctrl-A p] [Ctrl-A n] etc
[Ctrl-A n] until 'top' is onscreen
q [Ctrl-D]
[Ctrl-D] etc...
Or something along those lines. You don't need tabbed terminal apps after all. =)

Yes, this is documented in screen's man pages. But it's one huge man page and I thought maybe you'd be more inclined to read it if you knew great stuff like this are hiding there.
  Post a comment  •  Comments (2)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
[5,410 views]  View Printable Version
Compare two Mac-formatted text files UNIX
The standard UNIX (command-line) utility 'diff' compares two text files, showing you the lines which differ between the two. It works well for all UNIX text files, including most of those you will encounter in OS X (e.g. the plist files holding preference information).

But it isn't useful for comparing files which use the traditional Mac end-of-line marker ("\r") since the 'diff' utility, like most UNIX tools, expects lines to be ended with "\n". OS X itself and most OS X applications use "\n" as the end-of-line marker, but some applications which exist in both OS 9 and OS X versions use the traditional Mac "\r" end-of-line marker for their files. An example is iMovie - its project files are editable text but they use "\r" and hence cannot be usefully compared with 'diff'.

All of the above was a long-winded motivation for the following shell script (for use in the Terminal) which provides a 'diff' comparison of two traditional Mac ("\r") files. Read the rest of the article for the script...
read more (181 words)   Post a comment  •  Comments (3)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
[22,856 views]  View Printable Version
A command-line weather getter UNIX
I'm a big fan of the PERL scripts that have previously been posted here, especially the command line speech generator and the command-line alarm clock. I use these two so frequently that I wrote a script to go with them; it gets the current weather and daily forecast off of, outputting the information in an speech-friendly way. To use this script, you must have wget installed, which you can do in a number of ways (This hint explains how, or through fink if it's installed, or via

Read the rest of the article for the script...
read more (419 words)   Post a comment  •  Comments (8)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
[9,761 views]  View Printable Version
Change IP addresses from the Terminal UNIX
The System Prefs panel makes it easy to change or add IP addresses, but what if you want to do it automatically or remotely? Most Darwin documentation talks about a nifty, "nonexistent since the Public Beta" tool called ipconfigd.

After much, much experimentation and research, I learned that to successfully change IPs from the command line the hard way, you must manually create a ton of routes. However, the ipconfig tool (not ipconfigd, which is now a plugin to configd) will do much of it for you. After manually setting the ip address of your interface (probably en0), just delete the current default route and recreate a route to your router.

Read the rest of the article for a script which uses this fact to automatically assign the next available IP using this technique.

[<b>Editor's note:</b> I have not tested this script.]
read more (471 words)   Post a comment  •  Comments (3)  
  • Currently 2.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
[12,584 views]  View Printable Version
Search for commands by keyword in the Terminal UNIX
This trick may be obvious, but by combining a couple commands in the Terminal, you can search the descriptions of all the commands in that path. Open a Terminal and type:
 % whatis /usr/bin/* | grep "search string"
This will return the description of every command in that path and then filter it with your search string. This is a quick way to find a way of doing something, if you don't know all the commands. For example:
 % whatis /usr/bin/* | grep "memory"
leaks(1) - Search a process's memory for...
vm_stat(1) - show Mach virtual memory statistics
vmmap(1) - Display the virtual memory regions...
These example results were trimmed for width, but you get the idea...

[Editor's note: You can use this syntax to find anything on any path, of course. If you're just interested in user commands, you could also use man -k "search string" | grep \(1 to return the same results a bit faster. The 'whatis' version of the command will also only work if you have built the whatis databases - see this hint for more about the 'whatis' database.]
  Post a comment  •  Comments (7)  
  • Currently 2.50 / 5
  You rated: 1 / 5 (4 votes cast)
[4,936 views]  View Printable Version
Enable command-line portscanning UNIX
Just found this over at the forums (credit to kennethmac2000 for that). There is no real command for doing portscans in the Terminal, so instead of installing nmap, just use the Network Utility from the command line like this:
 % cd /Applications/Utilities/'Network'
% sudo cp Contents/Resources/stroke /bin/portscan
% rehash
Now you can do portscans from the command line using the following syntax:
portscan [address] [startPort] [endPort]
[Editor's note: I thought we had published something similar before, but I can't seem to locate it...]
  Post a comment  •  Comments (2)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
[5,570 views]  View Printable Version
Quickly define words in the Terminal UNIX
Add the following alias to your aliases.mine file to have an on-call dictionary at your fingertips:
alias dict 'curl dict://\!*'
Now to look up a word, just type dict word_to_define.

[Editor's note: There's at least one service (OmniDictionary) which will return the definition of a selected word if you prefer the GUI for your dictionary browsing ... but this is quite nice when you don't want to touch the mouse or the menu to define a word. Note that I have substantially (completely?) rewritten what Carthag submitted ... primarily because, although it was fun reading an IRC transcript, it really didn't fit the layout of the macosxhints page all that well! ;-)]
  Post a comment  •  Comments (4)  
  • Currently 3.00 / 5
  You rated: 4 / 5 (4 votes cast)
[7,117 views]  View Printable Version
Count all files in a folder hierarchy UNIX
In the Finder, it's relatively easy to see how many files are within one level of a folder, but I'm not aware of a way to see a count for all of the files in that folder hierarchy (anyone?).

Someone asked a similar question on the Macworld forums, and with some help from a friend, we managed to come up with a UNIX command string that will return the answer. Say you wish to count all the files in the folder "Stuff" stored on your desktop. Simply type the following into the Terminal:
  % cd ~/Desktop
% find "Stuff/" | wc -l
This will return a count all files, including invisibles and the top level "Stuff" folder itself. If you just want to see the visible files, use:
  % find "Stuff/" \! -name ".*" | wc -l
I'm not sure if this is the most efficient means of answering the question, but it seems to work reasonably quickly and it was accurate on all the folders I tested it on. Any other alternatives, in either the Finder or the Terminal?

If you'd like to know more about how the command works, or how to create a shortcut to make it easier to use in the future, read the rest of the article.
read more (314 words)   Post a comment  •  Comments (11)  
  • Currently 2.60 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
[71,087 views]  View Printable Version