Anyway, I couldn't always connect to my computer unless I checked the IP address before heading out and hoping it didn't change while I was gone. So I wrote a few scripts to automatically upload my IP address to the campus webserver and a redirect script to take me to my computer.
Read the rest of the hint for the how-to...
First, in a text editor, I modified a copy of my ~/.netrc file so that I could define a macro for ftp that would upload a given file when ftp was connected:
machine 111.111.111.111
login myUserID
password somePassword
macdef init
cd public_html
put ip.txt
bye
I named this copy of the file .netrc2 and it goes in my home directory. It specifies a machine and an automatic login for that machine. Then it defines a macro to upload ip.txt to public_html and then disconnects. Then I wrote a shell script and called it ftpmyip.sh and placed this file in ~/bin:
echo -n `ipconfig getifaddr en0` > ip.txt
cp /Users/myUserID/.netrc /Users/myUserID/.netrc.bak
cp /Users/myUserID/.netrc2 /Users/myUserID/.netrc
ftp 111.111.111.111
mv /Users/myUserID/.netrc.bak /Users/myUserID/.netrc
This script sends the result of ipconfig getifaddr en0 to a file called ip.txt. I needed to use the echo command to remove the endline character because I include the file as-is later on. It swaps my two .netrc files, so that the one with the macro definition is used and then swaps them back when it has disconnected. Then, I wrote a .shtml file to be placed on the campus webserver that would include a redirect javascript to my computer.
<html>
<head>
<title> Redirect </title>
</head>
<body>
<script language = "javascript">
<!-- the next line needs to be all on one line -->
document.location.href = "http://<!--#include virtual = 'ip.txt' -->/~myUserID"; </script>
</body>
</html>
I named this file redir.shtml. It has a server-side include, so you need to make sure that your webserver knows how to handle those. It also needs to be in the same directory as ip.txt.
Then from here, I simply wanted to shell script to run each time I log in. I could have created a conditional statement so that if the contents of ip.txt do not match the current IP then upload the new file, but bandwidth is not an issue here, and the script takes about one second to run. Furthermore, I'm a little bit lazy when it comes to making everything as efficient as possible. So what I did was called the shell script from an AppleScript, because it's easy to call AppleScripts at login:
do shell script "/Users/myUserID/bin/ftpmyip.sh"
You need the complete path to the script in AppleScript. Lastly, I set the AppleScript to run at login in the Login Items panel of the System Preferences.
Now, I can call up www.ourserver.edu/redir.shtml, and I'm taken directly to my computer. Because of the firewall and IP issues, this is only good on campus. From elsewhere, I'm not able to access my computer.

