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

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
fi
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.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,704 views] Email Article To a Friend 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.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[9,514 views] Email Article To a Friend 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 me@somewhere.edu
  • telnet 192.168.1.99
  • top
  • vi ~/Library/init/tcsh/aliases.mine
The titles appear alphabetically in Terminal.app'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)
 
[9,752 views] Email Article To a Friend 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,057 views] Email Article To a Friend View Printable Version
A hint for building Perl 5.6.1 UNIX
To build Perl 5.6.1 from source, you must patch hints/darwin.sh to add the following line *OR* edit config.sh 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,392 views] Email Article To a Friend 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
then
echo "exiting early"
exit
fi
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 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,017 views] Email Article To a Friend 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 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[6,951 views] Email Article To a Friend View Printable Version
An OpenSSH replacement UNIX
When I tried to access securely (with ssh) my work's server (remote) from my iBook (local1) running 10.1.2, I wasn't allowed in, whereas from the faculty's computer (local2), this was no problem at all. I worked through several ssh and sshd config files, but couldn't find any relevant differences, until I noticed that local1 had OpenSSH installed (OS X standard), while local2 and remote used the commercial SSH from SSH Communications Security.

I downloaded the source code at commerce.ssh.com, which is free for non-commercial use. It compiled right out of the box, and was installed in /usr/local, so my original OpenSSH is still intact in /usr. Now I can access remote just as easily from local1 as from local2.

I am somewhat confused, though, since I had supposed OpenSSH and SSH to be completely compatible. If for some reason you would like to run /usr/local/sbin/sshd instead of /usr/sbin/sshd, you could easily accomplish this by changing the relevant line in /System/Library/StartupItems/SSH/SSH.
  Post a comment  •  Comments (2)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[5,246 views] Email Article To a Friend View Printable Version
Compile GAIM on OS X UNIX
I got GAIM (the GTK+ based AIM compliant Real Time Chat Client) to compile in OS X by making the following modifications to the normal installation process:

use the '--disable-perl' flag for the configure script. This is because the libraries included by the perl support unfortunately conflict with the libdl.dylib. Hopefully someone will find a way around this.

After configure has finished point your favorite editor at plugins/Makefile and change line 315 from:
   @cp .libs/libtmp$@.so* $@
to
   @cp .libs/libtmp$@.dylib* $@
This will deal with OS X's use of the dylib suffix instead of good old .so when using libtool to build plugins.

Unfortunately, the build generates lots of errors and doesn't seem to be able to log in to AIM using OSCAR (the full AIM protocol) only TOC (the somewhat neglected open AIM protocol). But it beats the floating away window in the new AIM client and has plugin support.
  Post a comment  •  Comments (1)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[3,012 views] Email Article To a Friend View Printable Version
Launch Vim from any text widget UNIX
Stuff you'll need for this hint:Now, put them together. TextExtras allows you to run the text in an entry box through a pipe and replace the text with the pipe's output. We're going to set up a pipe for Vim. The tricky part is that Vim, being an editor, can't just read text from stdin, edit it, and write it back to stdout; it uses stdout for the editing interface. So we have to help it out a bit, and this is where vimwrapper.pl comes in.

Read the rest of the article for the details on this trick...
read more (237 words)   Post a comment  •  Comments (4)  
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[6,066 views] Email Article To a Friend View Printable Version