If you're like me, and you have an OS X work laptop that you bring home, you sometimes frustratingly find that the laptop will refuse to wake up when you get home, or it'll take a long time to wake up -- presumably because it's trying to find network resources that your office has, but obviously your home does not.
I've found a workaround that seems to have eliminated this problem for me completely. First, if you don't already, you should have separate network locations for your home and work. In my case, I use my laptop on an ethernet connection at work. So my Work location has every network port except Built-in Ethernet disabled. At home, I use my laptop on my wireless network, so my Home location has every network port except AirPort disabled.
I've created a third location, called NULL, which has all network ports disabled. Before leaving the office every day, I switch my location to NULL (using the Location option in the Apple menu), unplug my ethernet cable, and put the machine to sleep. When I get home, I open my MacBook Pro's lid, and it snaps awake instantly. Then I switch my location to Home and connect to my wireless network.
Before I started doing this, I'd see the spinning beachballs for two minutes fairly consistently. Now, I haven't had any problems. I'm guessing it's because, when you switch locations and a network port gets disabled, the operating system can inform the underlying network subsystem that this port is no longer available due to user intervention -- so all the resources that were coming through that port are gone as well. So there's no need for the network subsystem to wait for a time-out period to see if those resources will reappear, since it knows they won't.
To create the NULL location, go to the Location -> Network Preferences entry in the Apple menu. Then, from the Location menu, select New Location. Name it NULL or whatever you'd like. Once it's been created, switch to it in the Location menu. Then go to the Show menu and select Network Port Configurations. Then just uncheck everything.
Once you're done, hit Apply Now. You should be set.
There are a a number of hints here providing ways to create *.inetloc-based shortcuts for remote connections via SSH (secure shell), but these don't really allow ssh://email@example.com addresses or alternate ports (a must if the SSH server is internet-facing). The following method enhances the previous suggestions, and in addition, allows quick start of a session or scp from Terminal itself. For instance, rather than typing ssh -p 222 firstname.lastname@example.org, you'll be able to type ssh web, or use the ssh:// hint to create a quick access icon in the Finder.
To start, open Terminal and type the following:
$ cd ~/.ssh
$ nano -w config
You will have a blank file where you can create a three- or four-line shortcut entry for each host in the form of:
Press Control-X then Y to save. Obviously, replace the relevant bits above with the information specific to your SSH connections. The port line is optional, for those servers not on port 22.
Now to test. In Terminal, type ssh web (or whatever you named it), and ssh should start, switch you to the alternate user and port, and place you at the login. Now you can follow the other hints -- start Text Edit and write ssh://web. Highlight this and drag it to your Desktop or a folder. Now clicking this shortcut will start Terminal with an ssh session using your pre-configured host, login name, and port information.
I often have to do router configuration via a console port, so I use a Keyspan Serial Adapter to get access. Two problems then present themselves:
ZTerm is a horrible Mac OS X app. It hasn't been updated in five years or so, and isn't a Universal Binary. The developer doesn't seem in any hurry to rectify the situation. It is not worth the shareware fee in its current form.
Minicom requires installation of Fink or MacPorts and is overly complex.
Solution: Use screen, Terminal, and a little AppleScripting.
Looking through various hints (like this one, or on the icecast mailing list) about making your own streaming station with iTunes, I wanted something relatively simple. I just wanted to route all sounds coming from my Mac to a UNIX system (Solaris, in my case), and something like icecast was far more powerful than what I needed. I decided to make it UNIX way with maximum offload of a task to my Solaris box.
Preparation for solution is quite simple:
Get and install Soundflower -– this is the key component that'll allow routing of all sounds elsewhere.
Either from Fink or with DarwinPorts (now known as MacPorts) install EsounD package (we'll need the only esdrec utility from there, in fact)
On UNIX box prepare: netcat, lame, and any MP3 player (I use mplayer).
To actually stream do the following:
Use Soundflower (2ch) as default input and output device on the Mac.
On UNIX box, start the following: nc -l -p 2048 | lame -b 128 - - | mplayer -nocache - (change 2048 to any other port you want to use; -nocache was added to mplayer startup because on a Solaris box I have caching turned on by default). This will order netcat to listen on given port then pipe data through the MP3 encoder to a MP3 player.
On OS X type in Terminal: esdrec | nc hostname 2048 (modify hostname to match yours, same goes for port).
This idea is far more simple and gives a degree of possibility to put encoding where you want, but is less useful when you want to stream to several hosts at once (something you can do with icecast). If you prefer a more OS X-styled solution, you can play with MuSE and icecast, but the major drawback of such solutions is caching of stream everywhere so that sound will be delayed for several seconds.
If, like me, you use Parallels Desktop a lot on for-pay access points, or otherwise locked-down networks, where adding an additional MAC address to the same wireless card might cause problems, then this hint is for you.
A sign that you're having an issue is that you get the T-mobile authentication page, or none of the networks inside your Parallels virtual machines seem to work. You'll also note that the systems seem to be on the same subnet, e.g. 10.254.x.x.
The solution that I've found works is to go into Parallels' network configuration section, and tell it to bind to en0. Then go into the Sharing pane in OS X's System Preferences and tell it to share from AirPort to Ethernet. This has the effect of setting up NAT to your en0 interface, and Parallels hooks into that to get internet access. Since everything is masqueraded through your airport (en1) interface, it magically works.
Here's my setup: on my ethernet LAN, I have my mini, my Xbox, and a Windows PC; on my wifi LAN, I have my mini, my internet router, and two other Macs. So I was looking for something that I would install on my mini so that my router would be accessible to my Xbox and Windows PC, and that would allow me to connect to those two from any Mac. Basically, I needed to bridge my ethernet and wifi LAN using Mac OS X.
Use an Airport Express. Easy (simply configure the ethernet port with a static IP and disable all other features to have it bridge ethernet/wifi traffic), but not that cheap...
Use IPNetRouterX. It looked easy to use, but I didn't really like the idea of forking over US$100 for a proprietary piece of software.
Find some way to configure Mac OS X built-in ipfw/natd to do it.
I searched the web here and there, and nobody seemed to have done something similar.
Many devices connected to the network have an SNMP agent running that can give out some information about said device. This information can be accessed from the command line, but the commands are not really user-friendly.
So I have written a small CGI script that displays basic SNMP information in a web page. To use the script, simply install it into /Library -> WebServer -> CGI-Executables/ and access it using the local web server. The linked web page explains how to install the script.
[robg adds: To run the script, just make sure that Web Sharing is active, then enter http://127.0.0.1/cgi-bin/hostinfo in your browser's URL bar. I tested it, and it seems to work (though none of the machines on my network return any interesting info). I've also mirrored the file on macosxhints.com, in case the source vanishes someday.]
So you want to know how many days until your password expires in Active Directory (AD)? Here's the meat of the code you can run on any AD-bound OS X box, so long as your shortname is the same as the AD name:
I've created a 28KB zip file (ADexpire.zip; Hints mirror) that contains adexpirre.sh, adexpire.php, and adexpire.scpt (and application version) for client/server setup (with code comments). This works for the situation many are in at my work: their machines aren't bound to AD and they don't often log into the file services on an AD server to find out their password expiration! This allows one server to field queries and return a value via http to an AppleScript that runs as a login item.
Hopefully this will help someone else and even better; maybe someone way smarter than me does it in five lines in Perl! ;) Looking forward to the comments and revisions.
If, like me, you connect to many different networks (I'm a network consultant), then you probably find OS X's ability to create different locations a most useful tool. But how to back them up to reinstall or tranfer to a new machine? After a long search, eureka! They're all in one single file:
I have a machine at work and one at home (common problem, yes?) and I want to access the one at work from home via VNC. Well, to properly use that I need to login to the VPN and then login to the remote machine -- but I need to know the IP address, and since we use dynamic addressing, you know the rest.
I saw a whole bunch of scripts here for how to have your PowerBook phone home, but they didn't cut it -- too complex and ultimately not what I needed. So I made this simple script:
#Script name: writeip
# Get my Ethernet Adapter IP Address
# And write it to a file
ipconfig getifaddr en0 > ~/Desktop/IP.txt
# Copy that file to my iDisk
cp ~/Desktop/IP.txt /Volumes/<idiskname>/Documents/IP.txt
If I make sure that my iDisk is set to automatically mount on login (using login items you can select a volume to automatically mount), then this script will get my IP address, write it to a file, then copy that file to my iDisk. Simple enough for what I needed. I then set up cron (using Cronnix) to run the script hourly to make sure my IP is current.
[robg adds: Note that this method will return the machine's internal IP address, which won't be its public IP address if you're using a router, for example. Since the author is first connecting to a VPN, this works, as he can then access the machine via its internal IP. If you need the remote machine's public IP (if you're connecting from work to home, for instance, and you have a router at the house), then you'll need to use one of these hints.]