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

Use a CGI script to display SNMP information Network
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.]
  Post a comment  •  Comments (1)  
  • Currently 1.67 / 5
  You rated: 3 / 5 (3 votes cast)
 
[7,954 views]  View Printable Version
Show days left until Active Directory password expires Network
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:
#!/bin/bash
pwPolicy=60
user=`whoami`
#use dscl in ineractive mode to find out ADdomain
ADdomain="All Domains"
userRecord=`dscl localhost -read /Active\ Directory/$ADdomain/Users/$user`
lastpwdMS=`echo "$userRecord" | grep -i pwdLastSet | sed 's/pwdLastSet: //'`
todayUnix=`date "+%s"`
lastpwdUnix=`expr $lastpwdMS / 10000000 - 11644473600`
diffUnix=`expr $todayUnix - $lastpwdUnix`
diffdays=`expr $diffUnix / 86400`
daysremaining=`expr $pwPolicy - $diffdays`
echo $daysremaining
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.

[robg adds: I have no way of testing this one...]
  Post a comment  •  Comments (6)  
  • Currently 3.00 / 5
  You rated: 1 / 5 (5 votes cast)
 
[44,677 views]  View Printable Version
How to copy network location settings between machines Network
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:

/Library/Preferences/SystemConfiguration/preferences.plist

All you need to do is copy that file and restore it on the new machine.
  Post a comment  •  Comments (1)  
  • Currently 2.50 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[13,492 views]  View Printable Version
Yet another way to get a remote IP address Network
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:
#!/bin/sh
#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.]
  Post a comment  •  Comments (2)  
  • Currently 1.00 / 5
  You rated: 1 / 5 (2 votes cast)
 
[13,769 views]  View Printable Version
Yet another NAT / iChat fix Network
If you and the person you want to iChat to are both behind NATs, you could forward the ports at one or both ends (5060, 5190, 5297, 5298, 5678, 16384-16403). But what if both ends are unable to forward these ports (maybe it's not your network, or you can't) -- you wouldn't be able to iChat.

However, Hamachi supports Bonjour properly, and has an OS X version. If both of you fire up Hamachi, you can use iChat's Bonjour features to chat between you and the other person, over the internet, with audio and video chat. The disadvantage is that the CPU load may be a fair bit higher due to Hamachi's tunneling overhead. It works great for me -- I've done it, doing audio chats on a 12" 1.33GHZ PowerBook G4 to someone on a 1.0GHZ 12" PowerBook, and not noticed any system slowdown.

Is this a hint? It's not obvious to most others -- whenever I suggest it to someone else, I get a strange look from them as if it's a long way round, and usually get told it's not going to work. But it does, and does well.

[robg adds: We discussed Hamachi in this previous hint.]
  Post a comment  •  Comments (0)  
  • Currently 1.00 / 5
  You rated: 1 / 5 (3 votes cast)
 
[7,677 views]  View Printable Version
Multi homing is a networking timesaver Network
I have saved a lot of time by using the dual homing cpabilities of OS X - that is, its ability to connect to two networks at the same time. My home network uses a DSL connection and all the printers are wireless, but I prefer a wired cable modem connection when I am at my desk. OS X happily connects me to the internet at the faster cable modem speed, but allows me to print over the AirPort connection to my home network printers.

In my previous occupation, I was able to work on both the office network and through a wireless internet link; the OS just found what I needed on whatever network was required. No muss, no fuss, and no juggling of connections. I am set up to connect automatically to available networks, although AirPort does ask before joining any untrusted access points.

[robg adds: Though not exactly a hint in and of itself, not everyone may know that OS X can use two network connections at once, so I thought it worth publishing this...]
  Post a comment  •  Comments (13)  
  • Currently 2.00 / 5
  You rated: 3 / 5 (4 votes cast)
 
[14,279 views]  View Printable Version
Create quick-access ssh shortcuts Network
To quickly open an ssh connection from nearly anywhere on your Mac, do the following:
  1. Open TextEdit and type in your connection string in the form of: ssh://user@host.com
  2. Select the whole line and drag and drop it on the Desktop. The result will be a *.inetloc file.
  3. Move the file to any folder you like. I made one named ~/connections that holds all of my *.inetloc files. You can rename this file to whatever you like, and even change its icon.
  4. Now you can drag and drop the *.inetloc file to the Dock, the Finder's Sidebar or Tool bar, or to anywhere else. (It can even be selected with Spotlight)
  5. If you use LaunchBar, open the Launchbar Configuration screen (Command-Y) and add another rule for your connections folder. Now your SSH connections can be opened with LaunchBar. I believe you can do similar with LaunchBar and Quicksilver, enabling quick launching of your SSH shortcuts.
A more lengthy explanation is available in my blog, containing some screenshots as well.

[robg adds: This doesn't seem to work for a few of my sites, which use the domain in the username -- i.e. my command would look like this: ssh://robg@mydomain.com@www.mydomain.com. The dual @ signs seem to confuse the ssh command, resulting in an incorrect command format: ssh mydomain.com@www.mydomain.com. For my domains that don't use this format, however, this trick works quite well.]
  Post a comment  •  Comments (21)  
  • Currently 3.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[43,876 views]  View Printable Version
Create an alias to a top-level Samba folder Network
At our office, we have a mixed work environment of Windows and OS X machine. On Windows, you can mount network drives to common directories. For instance P: will take you to //network/pc05/projectsFolder. You can create an alias on OS X to a directory inside a mounted drive, such as this one...
//network/pc05/projectsFolder/project1
...but I haven't been able to create an alias to the shared folder itself (//network/pc05/projectsFolder).

I have tried to go to the /Volumes directory after mounting the folder and creating an alias from the mounted directory, but this doesn't always work, I don't know why, but sometimes I lose write priveliges if using that alias.

I just found out that if you create an alias to a directory, as in the project1 folder above, you can then use the Get Info (Command-I) command on the alias (with the network drive mounted). Click the Select new original button, and it will let you select the actual directory for the alias (//network/pc05/projectsFolder).

Then you just have to change the name of the alias to projectsFolder, and you have the equivalent of a mounted drive alias. I even created a folder, myNetwork, where I keep the all the aliases. Just put it on the Finder's sidebar, and you can quickly mount your network directories.
  Post a comment  •  Comments (6)  
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
 
[28,894 views]  View Printable Version
Mount a Linux home dir on a Mac via OpenVPN Network
I've compiled a detailed step by step explanation of how to mount your home directory on a Linux server (Debian GNU/Linux based) via a mini-VPN on your Mac. The How To uses OpenVPN and it's marvellous client counterpart Tunnelblick.

Here's a short summary of the steps involved:
  1. Download and install OpenVPN on your server.
  2. Configure OpenVPN on your server.
  3. Install and set up Samba on your server, if it's not there already.
  4. Start openvpn and samba.
  5. Download and install Tunnelblick on your Mac.
[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (11)  
  • Currently 2.83 / 5
  You rated: 5 / 5 (6 votes cast)
 
[39,069 views]  View Printable Version
Use an enhanced location changer script Network
MacWorld recently published a list of things they would most like to see in Leopard, and one of the first ones listed was the ability to automatically change a variety of settings according to network location. Several months ago, there was a posting here about a script called locationchanger, and since then, I have significantly expanded upon the original script, so I thought I'd share the fruits of my labors.

locationchanger (20KB download link, MacOSXHints mirror) is designed to automatically reconfigure many programs and resources according to IP address, wireless network ID, or dial-up connections. Currently it's capable of automatically modifying the following:
  • NFS automounts
  • Privoxy settings
  • host file settings
  • default printer
  • Mail server and account
  • iChat status
  • Location setting in Network Preferences
Additionally, if growl is found, it notifies you of the new IP address, location name, and the hardware device of the new connection. Comments welcome!

[robg adds: I haven't tested this one, but I know that location management is a topic of interest, so here it is. Please read the entire Read Me file before proceeding, as there are important notes in there. There's also a simple uninstall script, in case you change your mind.]
  Post a comment  •  Comments (8)  
  • Currently 2.33 / 5
  You rated: 3 / 5 (3 votes cast)
 
[15,924 views]  View Printable Version