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

Display remote uptime info UNIX
If you have multiple mac os x machines on a LAN, you can run rwhod found at /usr/sbin/rwhod; you will have to launch it with "sudo rwhod". If you run this on all machines on your LAN you can type ruptime and get the uptime of those machines:
[:/var/rwho] bryan% ruptime
www100 up 3+01:53, 1 user, load 1.12, 1.03, 1.01
www200 up 8+04:30, 1 user, load 1.99, 1.99, 1.99
[Editor's note: I could not get this to work on my machines; ruptime returns a "no hosts in /var/rwho" error message. Also, in trying to investigate why I was getting this message, I read a couple of articles that indicate that rwhod can flood a network with informational messages. These articles recommended disabling rwhod to improve network performance. Any thoughts on why I couldn't make this work, and/or on rwhod in general?]
  Post a comment  •  Comments (6)  
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
[4,708 views]  View Printable Version
More tcsh history command improvements UNIX
I've always hated the default command line completion settings in tcsh; they're too restrictive for me. I've been using JPSoftware's 4DOS/4NT command line processor on my Wintel PC for years and I love how they handle command completion. They have the TAB key cycle through all possible choices when there's more than one match, and they have the command history (up and down arrow keys) operate similarly. Also, if you simply type the name of a directory as the only argument on the command line, they treat it as the argument to the "cd" command and go to that directory.

You can make tcsh behave the same way by adding the following lines to your .tcshrc file:
# Make command completion (TAB key) cycle through all possible choices
# (The default is to simply display a list of all choices when more than one
# match is available.)

bindkey "^I" complete-word-fwd

# Make command history (arrow keys) use history search operations
# (The default is to simply display the next item in the history list.)

bindkey -k down history-search-forward
bindkey -k up history-search-backward

# Turn on implicit cd operation
set implicitcd
Check out the tcsh 'man' page; there's quite a lot in there.

[Editor's note: There are numerous other articles here that speak of where to save these commands in your user environment. For Apple's recommendation on the matter, type:
cat /usr/share/init/tcsh/README
This details the preferred structure on OS X.]
  Post a comment  •  Comments (2)  
  • Currently 3.33 / 5
  You rated: 2 / 5 (6 votes cast)
[13,843 views]  View Printable Version
Change a user's default shell UNIX
A MacOSXism that might throw more classically-aligned Unix folks is how to change a user's shell (or other passwd information, actually).

Classic wisdom suggests using standard methods such as vipw or chsh. However, these methods do not work under OS X, as I found out the hard way. If you try to use these methods which revolve around changing the passwd/master.passwd filles, you'll find that everything looks ok but that the system elements that use this information are ignoring your changes. This vexed me until I discovered that the true authoritative repository for this infomation is managed by NetInfo.

Read the rest of the article for the details on using NetInfo to change the shell, and some information on why this is advantageous over just setting the prefs in the Terminal application...
read more (242 words)   Post a comment  •  Comments (7)  
  • Currently 3.00 / 5
  You rated: 4 / 5 (7 votes cast)
[60,446 views]  View Printable Version
A fix for shared dial-up connection issues UNIX
Hi, not sure whether this was posted already. I had problems sharing a dial-up (Modem) PPP connection. I want to use NAT for security reasons and found that only the first connection after reboot worked. Subsequent connects would fail due to NATD not rebinding the new PPP bindings. Restarting NATD fixed the problem. Luckily PPPD fires off some scripts in /etc/ppp depending on connection status. The following script restarts NATD after every successfull connect if you save it as /etc/ppp/ip-up (don't forget to make it executable):
#!/bin/sh - 
N_P=`ps -uxc -U root | grep ' natd$' | awk '{ print $2 }'`
if [ "$N_P" != "" ]; then
logger -i -t $0 "Sending SIGHUP to natd (PID $N_P)"
kill -HUP $N_P
In that script you can, of course, kick off other useful stuff you only want to happen if the link comes up (e.g. sending spooled mail).
  Post a comment  •  Comments (3)  
  • Currently 1.50 / 5
  You rated: 1 / 5 (4 votes cast)
[4,890 views]  View Printable Version
Remove case sensitivity from auto-completion UNIX
For everyone out there that is bothered by the case-sensitivity of auto-completion in the Terminal, you have an option. Just open a terminal window and type:
  set complete = enhance
Alternatively, you can put this command in your .tcshrc file (if you've created one in your home directory). This setting seems to be saved somewhere, although I'm not sure where. Therefore, once you entered it (or put it in you .tcshrc file), it should stick even if you delete that line from .tcshrc at a later time.

If you're not sure what I'm referring to, try the following (before setting autocomplete to enhanced mode). Go into the terminal and type:
  cd /app [and then hit tab]
The autocomplete won't work, as the Applications folder is capitalized (or at least it is on the default install). Now try the following:
  cd /App [and then hit tab]
This should pop out to:
  cd /Applications
After you've tweaked the 'complete' setting, it will ignore the case of your entry and autocomplete based on the character(s) alone, regardless of case.

From playing around with it, it seems that typing:
  set complete
with no modifiers will bring back the case-sensitivity, although I haven't tested this thoroughly.

Panther broken!
  Post a comment  •  Comments (13)  
  • Currently 1.67 / 5
  You rated: 2 / 5 (3 votes cast)
[10,166 views]  View Printable Version
Display current jobs in Terminal titles UNIX
This is a follow-up to cft's earlier tip which showed how to put the current working directory in a terminal window's title. Another nice possibility is to display instead the current job. For instance, right now I have six terminal windows with these titles (quite a bit more informative than ttyp1 thru ttyp6...):
  • cal 2002
  • man tcsh | grep alias
  • ssh
  • telnet
  • top
  • vi ~/Library/init/tcsh/aliases.mine
The titles appear alphabetically in's "Window" menu, and are also attached to minimized windows in the dock.

The way to do this is explained in Ric Lister's Xterm-Title Howto and is easy to summarize. First, issue the last command above ("vi ~/Lib...") to create and edit a file named 'aliases.mine' in the appropriate directory. This standard location is defined in /usr/share/init/tcsh/README. Next, type "i" and insert this line:
sched +0:00 alias postcmd 'echo -n "^[]0;\!#^G"'
As in the earlier tip, ^[ and ^G here are not to be typed literally. They are the ESC and BEL escape sequences, obtained in vi by typing ctrl-V ctrl-[ for the first one and ctrl-V ctrl-G for the second. Finally, save and close the file (esc :wq! return), open a new terminal window, and marvel.

Addendum to original story: Based on the long series of comments below, here is a version of the command to use which will not cause errors and seems to work in all situations:
sched +0:00 alias postcmd 'echo -n "^[]0; `hostname|cut -d.[space]
-f1`: `echo \\!# | cut -b 1-25`^G"'
Please note it is shown on two lines, but is really one long line. Replace [space] with an actual space character and enter as one line of text.

Second addendum: From the original author, here's a newer version that actually works in all situations (even the above one causes some errors in certain circumstances):

sched +0:00 alias postcmd 'printf "\033]0; %s \007" "\!#:q"'
I have tested this new version, and it works just fine in tcsh...
  Post a comment  •  Comments (30)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
[10,363 views]  View Printable Version
localhost fix for mySQL JDBC driver UNIX
On his excellent MySQL for OS X page, Marc Liyanage offers up some sample code for testing MySQL with JDBC.

It's a good simple example, but unfortunately it's unlikely to work, because of modifications that must be made to the permissions table in MySQL.

The README that comes with the mm.Mysql driver suggests that granting permissions for user@locahost will solve the problem, but unfortunately, OS X does not seem to resolve "localhost" in many instances. This seems to be one of them.

The answer is posted on the sourceforge forums; I'm providing a link because the solution wasn't mine to offer. I just happened to find it on the 'net and thought it should be on the OS X Hints site too.
  Post a comment  •  Comments (0)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
[6,744 views]  View Printable Version
A hint for building Perl 5.6.1 UNIX
To build Perl 5.6.1 from source, you must patch hints/ to add the following line *OR* edit to alter the line:

OLD: firstmakefile='makefile'
NEW: firstmakefile='fmakefile'

The reason is the default perl distribution has this filename, a temp file, set to 'makefile'. Due to the case insensitivity of HFS+, the important file "Makefile" is deleted when the build scripts try to delete the temp file "makefile".

Note: I still don't have Perl building properly but this is a big step in the right direction.
  Post a comment  •  Comments (6)  
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
[2,591 views]  View Printable Version
Active connection check in firewall scripts UNIX
Many folks out there have been using ipfw with their OS X machines. Unfortunately, many scripts out there in tutorials will hang if your machine is not connected/dialed into a network.

I've found this issue can be easily solved by adding the following lines at the top of your firewall script (right after the top #! line):
if ! ifconfig -a | grep "status:" | awk '{ print $6 }' | grep "^active" > /dev/null
echo "exiting early"
This will run ifconfig and check for active interfaces. Note that all interfaces seem to be up in OS X, whether they are actually connected to a network or not. If it doesn't find any, it will abort the script, thus not hanging forever.

I use my script additions with a script I modified from here.
  Post a comment  •  Comments (2)  
  • Currently 4.50 / 5
  You rated: 4 / 5 (2 votes cast)
[3,153 views]  View Printable Version
Quick and easy mySQL and PHP installs UNIX
After much searching, reading out of date articles for old versions of OS X, and even trying my own installation of PHP from source (disaster), I eventually found this site run by Marc Liyanage and in no time at all I had PHP, MySQL etc running fine.

Now I can develop my sites from home without disturbing the live version until I've finished ! He seems to keep it very up to date - current version of PHP is 4.1.1 and he offers source code or binaries.

[Editor's note: Marc's site has been mentioned here before, and it's linked on the links page, but it's worth a mention directly as a hint. If you're trying to get mySQL, PHP, and other UNIX tools installed on your Mac, Marc's done some great work! His mySQL package allowed me to get mySQL installed and running on an iBook in about five minutes!]
  Post a comment  •  Comments (4)  
  • Currently 2.50 / 5
  You rated: 4 / 5 (2 votes cast)
[7,217 views]  View Printable Version