Archive for September, 2006

This is Weird!

September 25, 2006

Hi all,

if you know a nerd, or if you are one ;-), you have to watch Weird Al‘s new video “White and Nerdy”. You can watch it here, for example. But please be careful: Don’t download this song!

Have fun!

Advertisements

Automatic proxy switching in Firefox

September 18, 2006

After each installation of Firefox, I always installed the SwitchProxy extension which I found quite useful, as I sometimes am connected directly to the internet, and at other times, when connected through VPN, I am using a proxy. The SwitchProxy extension allows me to choose the correct proxy in a menu bar, so I don’t have to go to “Tools->Options->General->Connection Settings” and choose the correct proxy settings.

The problem with that extension, as with all extensions, is that you typically have to reinstall an up-to-date version after a new release of Firefox is out. So I tried to find more information about the syntax and capabilities of the automatic proxy configuration file and found quite useful information in Wikipedia and at Mozilla. Although most documents only describe the http:// URL, it’s (of course) also possible to use the file:// URL for the proxy config file. Might be useful if you do not have write access to a web server…

Let the browser find your proxy

Just create a local file /etc/proxy.pac, /home/<username>/cfg/proxy.pac, or C:\cfg\proxy.pac (or whatever path you like) in your current operating system environment, and replace the string proxy.domain.xxx:8080 with your specific proxy host name and port:

function FindProxyForURL(url, host) {
return "PROXY proxy.domain.xxx:8080; DIRECT";
}

Then, enter the following in your Firefox proxy settings, in the line Automatic Proxy Configuration URL:

file:///etc/proxy.pac

or, in Windows:

file:///C:/cfg/proxy.pac

and click “OK”. That’s all.

BTW – Lots of examples for automatic proxy config files can be found when searching the web for the string “FindProxyForURL”

log file monitoring using tail -f, (n)awk, mailx and xmessage

September 6, 2006

From time to time, I would like to monitor one or more of my log files, e.g. the web server’s access log.

Here’s a short script that I use for monitoring the apache log. It:

  1. sends an email (via mailx)
  2. creates a popup window (via xmessage)

For the popup window to be created, the X server must be allowed to display the application, using xauth or xhost. Instead of xmessage, you may also use zenity (which comes with Solaris).
Don’t forget to customize the recipient’s email address (RECIPIENT) and the name of the file that is to be monitored (FILE_TO_MONITOR) before using the script!

The Script

#!/bin/ksh
# monitor-apache-log: notify when new entries in apache log matches search string
# notification by email and xmessage popup
# email subject contains all relevant information - see below
# argument: string to search for in the log file
# customize:
RECIPIENT=email-address-to-use-for-notification
FILE_TO_MONITOR=/var/apache/logs/access_log
# end of customization
# access_log fields used:
# $1      = IP address of client
# $(NF-3) = name of file
# $NF     = size of file
# prepend \ before any / so the search string can be used in (n)awk even if it contains "/":
SEARCH_STRING=$(echo $1 | nawk '{gsub ("/", "\\/"); printf ("%s", $0)}')
tail -f ${FILE_TO_MONITOR} | \
nawk '/'${SEARCH_STRING}'/{system ("echo \"\"|mailx -s \""$1" "$(NF-3)" "$NF"\" '${RECIPIENT}'; xmessage -geometry 800x200 -bg red -fn \"-adobe-helvetica-bold-r-*-*-18-*-100-100-p-*-iso8859-1\" -nearmouse \""$1" "$(NF-3)" "$NF"\" &")}'