Wednesday, March 31, 2010

Run Google Chrome through a proxy server

There is no option in the preferences of Google Chrome to enter a proxy server, but it is possible to specify one using command line arguments. You have to execute the Google Chrome binary inside the application bundle from terminal. First open terminal and then cd to your applications directory or wherever Chrome is stored.

cd /Applications

Next start chrome with the proxy server option:

Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server="socks5://host:port"

Replacing host and port with your information. Keep in mind that although HTTP requests are being serviced through the proxy DNS lookups are not going through the proxy server. You can add "&" to the end of the command to have it execute in the background.

Tuesday, January 26, 2010

Browse The Web With Blazing Speed!

No I'm not talking about downloading the latest beta version of Google Chrome. Want to run the browser with the fastest rendering time out there ? Try out Lynx, a text based command line browser for Unix. It is really easy to build and install Lynx in a few minutes and you have a fully functional web browser you can use from the command line. I used the following commands to download and install Lynx:

curl ftp://lynx.isc.org/lynx2.8.7/lynx2-8-7.zip > lynx2-8-7.zip
unzip lynx2-8-7.zip
cd lynx2-8-7/
./configure
make
sudo make install

(Note I built Lynx on OS X 10.5.7 PowerPC)

Thats it, you should have a working version of lynx, to take it for a test drive try

lynx http://www.google.com/

Monday, January 18, 2010

Backticks and Percent Signs in Crontab

I setup a cron job recently and got a strange error message emailed to me even though I had tested the command out beforehand. I initially though it had to do with using backticks, but it turns out it had to do with unescaped percent symbols.

It is possible to use backtick's in the crontab, however if you use them in a statement like this:
0 * * * * perl script.pl /tmp/`date %Y-%m-%d`.csv

You will get a very cryptic error message. The reason for this is the % character has special meaning in the crontab and must be escaped to work properly. So the above command would look like:
0 * * * * perl script.pl /tmp/`date \%Y-\%m-\%d`.csv

Monday, January 11, 2010

Passive FTP on Leopard Server

I ran into some major problems today attempting to setup Passive mode FTP services on Leopard Server. I turned on FTP services using Server Admin, and I also went into the software firewall and enabled the provided rule for FTP Passive. I connected to the FTP server using the command line client from terminal without any issues, but as soon as I attempted a directory listing (ls), my ftp client would hang for about five minutes and finally return the listing.
In passive mode an FTP client connects to the server and issues a PASV command to let the server know it is in Passive mode, the server responds with a random port, within whatever the default port range that particular server uses. The client then connects to that port. In order for Passive FTP to work properly you must have that entire port range open in your server firewall.
It seems that Leopard server's default firewall rule for Passive FTP uses a subset of the ports the FTP server provided with Leopard uses. The firewall rule opens ports 49152 - 65535, while the FTP server uses ports from 1023 - 65535. The easy solution to this problem is to create a custom firewall rule and open all ports, but this is not a good idea.
The solution it turns out is to edit the FTP configuration file and specify the same range of ports as the Leopard software firewall. Although Server Admin provides some limited configuration options for FTP it does not allow you to edit the port range. You need to edit the file /Library/FTPServer/configuration/ftpaccess, I added the following line to the top of the file: passive ports 0.0.0.0/0 49152 65535, I then started and stopped FTP service using Server Admin. This solved my problem and I was able to connect to the FTP service normally.