Web Access through Proxy Server by Terminal Applications


In many companies/Universities, the web access is granted through Proxy Server (Usually SQUID; hence port 3128).
There are many terminal applications (run on command line interface), which access Internet/Web. For example:
wget (to download file), ftp, lynx/links (to access website), apt/yum (to download and install package). If we are behind
proxy, these applications do not work. The easy solution is to set some shell environment variables, explained below:

For accessing web(lynx/links) using a non-authenticated proxy:
$ export http_proxy=”http://proxy.yourcompany.com:3128″

Verify that the setting took place
$ echo $http_proxy
http://proxy.yourcompany.com:3128

For accessing web(lynx/links) using a authenticated proxy:
$ export http_proxy=”http://username:password@proxy.yourcompany.com:3128″

If you want the change to be permanent (there each time you open a terminal),
add the export line to .bashrc in your ‘home’ directory.
$ echo ‘export http_proxy=”http://proxy.yourcompany.com:3128″‘″ >> ~/.bashrc

Secure HTTP (over SSL) access
$ export https_proxy=”https://proxy.yourcompany.com:3128″

FTP access
$ export ftp_proxy=”ftp://proxy.yourcompany.com:3128″

Viewing PDF Files on Terminal


First you need to convert a PDF document to HTML, then you run it through the elinks pager. There’s a fine utility for doing just that, and it’s called (appropriately) pdftohtml. You can find the home page for pdftohtml. If pdftohtml isn’t already installed in your distribution of Linux, or isn’t on your CD set, it’s commonly available for Debian and RPM-based distributions, such as Fedora, SUSE, and more. The elinks program is also easily available if it isn’t automatically installed in your distribution.
For example, you can install pdftohtml and elinks in Debian Linux with this command:
# apt-get install pdftohtml elinks

Users of the yum package can get the RPM version with this command:
# yum -y install pdftohtml elinks

Now you can view a PDF document with the following command. This particular command has one drawback. The output will not include frames (PDF files generally have a frame on the left that lets you jump to different pages).

$ pdftohtml -q -noframes -stdout document .pdf | elinks

If you want the left frame of page numbers, you can always use the following command instead:

$ pdftohtml -q document .pdf ; elinks document .html

You can write a script to save you all this typing each time you view a document. Use sudo or log in as root to create the /usr/local/bin/viewpdf script and enter the following code:

#!/bin/bash

pdftohtml -q $1 ~/temp.html
elinks ~/temp.html

#
#end of script

This code assumes it’s OK to store the temporary HTML file in your home directory. You can use another location if you prefer. Now save your work and make the file executable:

$ sudo chmod +x /usr/local/bin/viewpdf