Search This Blog

Saturday, March 22, 2008

accessing wpa wireless networks

This article explains accessing a wireless connection with WPA TKIP encryption using a Dell Inspiron E1505 laptop running Debian Etch. The final network connection is going to look like

ISP <---> wrt54g router <---> Dell Inspiron E1505 laptop

where ISP is the Internet Service Provider such as roadrunner, comcast etc., (and in my case "clarity connect").

The main steps involved are
  1. configure the router
  2. Install the necessary software packages on the Debian machine
  3. encrypt the password (if necessary)
  4. add a network stanza in /etc/network/interfaces
  5. restart the network

The information about the wireless card can be found by using
sudo lspci --vv
In this case, we have
0b:00.0 Network controller: Intel Corporation PRO/Wireless 3945ABG Network Connection (rev 02)
The router is configured as shown below.





The SSID stands for "Service Set Identifier". It is basically the name of the wireless network. In this example, it is set to "Raju_and_Satish". Change the SSID according to your network.

A list of available networks and their SSIDs can be obtained by using
iwlist scan

As can be seen from snapshot 2, the router is configured to use TKIP as its WPA encryption algorithm.

The "WPA Shared Key" (snapshot 2) is the place holder for setting a password to the network. Since the password is usually a bunch of ASCII characters, it is also referred as a "passphrase". In this example, the password for the network is "strongpassword". Change it according to your network.


Install the necessary software by using the apt-get command. I have installed
  • firmware-ipw3945
  • ipw3945-modules-2.6-686
  • ipw3945-modules-2.6.18-6-686
  • ipw3945d
  • wpasupplicant
I am not sure if all the above packages are needed for the network configuration, but I know that they are sufficient. If anyone knows a leaner version of the necessary packages, please let me know and I will update this list.


The next step is to generate an encrypted string known as the pre-shared key (PSK) from the ASCII password and the SSID. This can be achieved using the wpa_passphrase command.
$wpa_passphrase Raju_and_Satish strongpassword
network={
ssid="Raju_and_Satish"
#psk="strongpassword"
psk=604d8887badd597a8647f65b98c3c504ad29ba352211033adfed01cd8c3034a0
}

After this, add the following stanza to the /etc/network/interfaces.

# wireless setup
auto eth2
iface eth2 inet dhcp
wpa-conf managed
wpa-ssid Raju_and_Satish
wpa-key-mgmt WPA-PSK
wpa-psk 604d8887badd597a8647f65b98c3c504ad29ba352211033adfed01cd8c3034a0

Replace the wpa-ssid, wpa-psk with the values corresponding to your network configuration.

Then restart the network connections by doing
$sudo /etc/init.d/networking restart

Now the network should be up and running. Its status can be tested by using host, ping commands.

$host www.google.com
www.google.com CNAME www.l.google.com
www.l.google.com A 216.239.51.104
www.l.google.com A 216.239.51.99

$ping -c3 www.google.com
PING www.l.google.com (216.239.51.99) 56(84) bytes of data.
64 bytes from 216.239.51.99: icmp_seq=1 ttl=242 time=40.7 ms
64 bytes from 216.239.51.99: icmp_seq=2 ttl=242 time=40.9 ms
64 bytes from 216.239.51.99: icmp_seq=3 ttl=242 time=39.6 ms

--- www.l.google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10124ms
rtt min/avg/max/mdev = 39.616/40.437/40.985/0.635 ms

Tuesday, February 26, 2008

weather in ithaca

To find the weather in Ithaca using a Linux box, add the following lines to the ~/.weatherrc . Use /etc/weatherrc for site-wide configuration.
$cat /home/rajulocal/.weatherrc
[default]
City = ITHACA
Forecast = True
ID = KITH
St = NY
After that you can get the current weather conditions and forecast by using the weather command.
$weather
Current conditions at Ithaca Tompkins Regional Airport (KITH)
Last updated Feb 26, 2008 - 05:56 PM EST / 2008.02.26 2256 UTC
Wind: from the WNW (300 degrees) at 3 MPH (3 KT)
Sky conditions: obscured
Weather: light snow; mist
Precipitation last hour: A trace
Temperature: 31.1 F (-0.5 C)
Relative Humidity: 95%
City Forecast for Ithaca, NY
Issued Tuesday afternoon - Feb 26, 2008
Tuesday night... Low 21, 100% chance of precipitation.
Wednesday... Snow showers, high 22, 80% chance of precipitation.
Wednesday night... Low 9, 40% chance of precipitation.
Thursday... Very cold, high 19.
Thursday night... Low 9.
Weather uses METAR data that it fetches from the the National Oceanic and Atmospheric Administration and forecasts from the National Weather Service. The list of weather stations and their codes can be obtained from http://www.rap.ucar.edu/weather/surface/stations.txt .

Tested on Debian Etch using
$weather --version
weather 1.2
Related links :-
  1. http://debaday.debian.net/2007/10/04/weather-check-weather-conditions-and-forecasts-on-the-command-line/
  2. http://www.rap.ucar.edu/weather/surface/stations.txt
  3. http://en.wikipedia.org/wiki/METAR

Thursday, November 22, 2007

browse gcc source code

To browse the source code of gcc use http://gcc.gnu.org/viewcvs/ . For example, to look at the contents of trunk/gcc/testsuite/gcc.c-torture/execute/ directory, just go to http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gcc.c-torture/execute/ . Similarly, to view the contents of a particular file, say pr34130.c use http://gcc.gnu.org/viewcvs/trunk/gcc/testsuite/gcc.c-torture/execute/pr34130.c?revision=130258&view=markup

Situation:
Recently, a miscompilation bug has been discovered in gcc. It affects all the gcc versions from 3.3.6 to 4.2.2. This bug is fixed in 4.3.0 and a testcase trunk/gcc/testsuite/gcc.c-torture/execute/pr34130.c has been added to the testsuite so that the same problem does not arise in the future versions. I wanted to take a quick peek at this file but was not ready to download 1.2 gigabytes of gcc's svn repository just for this. The above tip came in handy under this scenario.

Alternate solutions:
1. If you are familiar with svn, it is possible to do
svn -q co svn://gcc.gnu.org/svn/gcc/trunk/gcc/testsuite/gcc.c-torture/execute execute
and download just the trunk/gcc/testsuite/gcc.c-torture/execute directory.

Related links :-
  • http://gcc.gnu.org/svn.html
  • http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34130
  • http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=452108

Saturday, October 13, 2007

list of predefined macros

Situation:

guile-1.8_1.8.2+1 failed to build on alpha architecture. The complete build log can be found at http://buildd.debian.org/fetch.cgi?&pkg=guile-1.8&ver=1.8.2%2B1-1&arch=alpha&stamp=1188086025&file=log

The buildlog tells us that the problem is in line 96 of test-round.c . To debug the problem further, the source of guile-1.8 can be downloaded by using

$cd practice/guile/
$apt-get source --download-only guile-1.8
$dpkg-source -x guile-1.8_1.8.2+1-2.dsc
$cd guile-1.8-1.8.2+1/

To see where test-round.c is residing

$find . -iname '*test-round.c*'
./test-suite/standalone/test-round.c

Now when we look at the source code of test-round.c around line 96

$cd test-suite/standalone/
$vim +96 test-round.c

we find that there is a predefined macro called DBL_MANT_DIG . But what is its value? More generally, how can we get a list of all the predefined macros and their values?

Solution:
The answer is surprisingly simple. Just do

$g++ -E -dM - < /dev/null

#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __DEC64_DEN__ 0.000000000000001E-383DD
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 2147483647
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 2
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 3
#define __DEC64_MAX_EXP__ 384
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINTMAX_TYPE__ long long unsigned int
#define __linux 1
#define __DEC32_EPSILON__ 1E-6DF
#define __unix 1
#define __LDBL_MAX_EXP__ 16384
#define __linux__ 1
...

Since our interest is in the predefined macro DBL_MANT_DIG, the above output can be filtered by using grep.

$g++ -E -dM - < /dev/null | grep -i __DBL

#define __DBL_MIN_EXP__ (-1021)
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_DIG__ 15
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_HAS_INFINITY__ 1
#define __DBL_MAX_EXP__ 1024
#define __DBL_MIN__ 2.2250738585072014e-308
#define __DBL_HAS_QUIET_NAN__ 1
#define __DBL_HAS_DENORM__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __DBL_MAX_10_EXP__ 308

This clearly tells us that DBL_MANT_DIG is 53 on this particular machine. More information about macros like DBL_MANT_DIG can be found in files
  • /usr/share/doc/glibc-doc-reference/html/Floating-Point-Parameters.html
  • /usr/share/doc/glibc-doc-reference/html/IEEE-Floating-Point.html
  • /usr/share/doc/glibc-doc-reference/html/Library-Summary.html
etc., which are all part of glibc-doc-reference package. On a Debian machine, this package can be installed by doing

$apt-get install glibc-doc-reference

Monday, October 01, 2007

websites incompatible with iceweasel

As we all know, iceweasel is basically a renamed version of firefox in Debian. The renaming was due to licensing issues. Except for the renaming there is no difference between firefox and iceweasel.

The following are the list of websites that wont work properly with iceweasel. The tests are performed with iceweasel 2.0.0.16, Debian Etch (Stable).


It is not very difficult to design a website which works the same way on all the browsers. I wonder why these companies are so incompetent in putting up a W3C standard complaint web site and not use any proprietary software. It also makes one wonder, if it would be better to take the business to companies who have the decency/ability to set up a browser-friendly website?

Updated on : Sep 25, 2008; Oct 1, 2007

Update on: July 27, 2014
On a machine runing Debian Jessie, iceweasel  30.0

Monday, September 03, 2007

initializing multi dimensional arrays in octave

In octave, multi dimensional arrays can be initialized using the reshape function. As an example, consider the following script.

$cat multidimensional_array.m
1;
a = zeros(1, 24);
for i=1:24
a(i) = i;
end
a
b = reshape(a, [4 3 2])

The output looks as follows

$octave -q
octave:1> multidimensional_array
a =

Columns 1 through 16:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

Columns 17 through 24:

17 18 19 20 21 22 23 24

b =

ans(:,:,1) =

1 5 9
2 6 10
3 7 11
4 8 12

ans(:,:,2) =

13 17 21
14 18 22
15 19 23
16 20 24



octave:2>

Wednesday, August 29, 2007

thecarpcstore website is down

$date
Wed Aug 29 13:16:35 EDT 2007

In case you do not know, the support forum for complainterator hosted at http://thecarpcstore.com/phpbb2/ is currently down due to a massive DDoS attack. This is the second time spammers have DDoSed complainterator forums. On a positive side, this shows what an enormous effect complainterator reports are having in shutting down spammer's websites. Good job complainterator! You rock!

Related Links :
  • http://complainterator.com/news.html
  • http://weblog.complainterator.com/

Tuesday, August 14, 2007

gmail and orkut got hacked or what?

$ date -R
Tue, 14 Aug 2007 20:34:30 -0400

Am I seeing this correctly? Did someone really manage to hack into google's servers? Some of google's popular websites such as gmail, Orkut seem to be down. I assume it is a temporary problem (a DDOS attack?). Whatever it is, it is impressive to see some non-english garbage on these popular websites.

Oh, I almost forgot, here are the screenshots for posterity :-)


Tuesday, July 17, 2007

tabs inside krusader

Krusader is a very nice file manager with lots of features. One thing that I find useful everyday is its ability to have multiple directories in different tabs. The following screenshot shows the location of these tabs in both the panes.




Here I am using Debian Etch (Stable), Qt: 3.3.7, KDE: 3.5.5, Krusader: 1.70.1 "Round Robin" . The above screenshot is produced by ksnapshot, edited by kolourpaint.

Thursday, June 21, 2007

Special shell variables in bash

Bash defines some special variables which are useful while writing shell scripts. They are

$0 = Filename of script
$1 = Positional parameter #1
$2 - $9 = Positional parameters #2 - #9
${10} = Positional parameter #10
$# = Number of positional parameters
"$*" = All the positional parameters (as a single word)[*]
"$@" = All the positional parameters (as separate stings)
${#*} = Number of command line parameters passed to script
${#@} = Number of command line parameters passed to script
$? = Return value
$$ = Process ID (PID) of the script
$- = Flags passed to script (using set)
$_ = Last argument of previous command
$! = Process ID (PID) of last job run in background

[*] Must be quoted, otherwise it defaults to "$@"

Reference :- Appendix B of "Advanced Bash-Scripting guide" by Mendel Cooper, Version 5.0. Debian users can get this document by installing the abs-guide package.

sudo apt-get install abs-guide

The necessary files can be found in /usr/share/doc/abs-guide . However, the abs-guide package contains only the html version of the document. A pdf version can be downloaded from http://www.tldp.org/LDP/abs/abs-guide.pdf .

Tuesday, June 12, 2007

which manpage am I looking at?

Q. which manpage am I looking at?
A.

man -w keyword

gives the filename of the manpage that would be displayed when

man keyword

is entered at the commandline.

To get a list of all plausible manpages use

man -aw keyword

The -w option works for info also.

Q. which info page am I using?
A.

info -w keyword

gives the path of the info file that would have been displayed if the command "info keyword" is used.

Ref :- The manpages of man, info!

Tuesday, June 05, 2007

Stapling paper

When stapling a bunch of letter or a4 sized sheets, staple sizes can be chosen using the following table.

Number of sheets Stack height Staple size
25 1/8'' 1/4''
60 1/4'' 3/8''
90 5/16'' 1/2''
160 9/16'' 3/4''

I assumed the thickness of paper is roughly around 0.1 mm (which might not always be correct!).

Disclaimer: The above info is just a guideline. Use it at your own risk. I am not responsible for any losses that you may incur due to using it.

Tuesday, May 15, 2007

updating texmacs to new upstream release

As of Tue, May 15, 2007 Debian contains the following versions of Texmacs.

Stable (Etch) : 1:1.0.6-10
Testing (Lenny) : 1:1.0.6-11
Unstable (Sid) : 1:1.0.6.9-4

On my system, I am using Debian Etch, texmacs 1.0.6.9-2. Couple of days back, texmacs released 1.0.6.10. As a maintainer of this package, I want to build the 1.0.6.10 package which can eventually be uploaded to Debian Sid. This document provides a recipe of commands to achieve this goal.

Here I assumed that you are using pdebuild for the first time. If you have used it before, skip the appropriate steps.

$cp /usr/share/doc/pbuilder/examples/pbuilder-distribution.sh ~/bin/pbuilder-sid
$mkdir -p ~/pbuilder/result
$sudo aptitude install cdebootstrap
$pbuilder-sid create # if second time, use 'pbuilder-sid update'

$cat ~/bin/pdebuild-distribution.sh
#!/bin/sh

DISTRIBUTION=`basename $0 | cut -f2 -d '-'`
BASE_DIR="$HOME/pbuilder"
pdebuild --buildsourceroot fakeroot \
--buildresult $BASE_DIR/result \
--auto-debsign \
-- --basetgz $BASE_DIR/$DISTRIBUTION-base.tgz \
--distribution $DISTRIBUTION $@

$cp ~/bin/pdebuild-distribution.sh ~/bin/pdebuild-sid
$chmod +x ~/bin/pdebuild-sid

$cd ~/practice/

Obtain the latest source from texmacs website

$wget ftp://ftp.texmacs.org/pub/TeXmacs/targz/TeXmacs-1.0.6.10-src.tar.gz

Rename the upstream sources

$tar xzvf TeXmacs-1.0.6.10-src.tar.gz -C .
$mv TeXmacs-1.0.6.10-src texmacs-1.0.6.10
$tar czvf texmacs_1.0.6.10.orig.tar.gz texmacs-1.0.6.10
$rm -rf TeXmacs-1.0.6.10-src.tar.gz texmacs-1.0.6.10
$ls texmacs*
texmacs_1.0.6.10.orig.tar.gz

Obtain the latest sources available in Debian Sid

wget http://ftp.debian.org/debian/pool/main/t/texmacs/texmacs_1.0.6.9.orig.tar.gz
wget http://ftp.debian.org/debian/pool/main/t/texmacs/texmacs_1.0.6.9-4.dsc
wget http://ftp.debian.org/debian/pool/main/t/texmacs/texmacs_1.0.6.9-4.diff.gz

Create the corresponding Debian source for 1.0.6.10

$dpkg-source -x texmacs_1.0.6.9-4.dsc
$cd texmacs-1.0.6.9/
$uupdate -u ../texmacs_1.0.6.10.orig.tar.gz
New Release will be 1:1.0.6.10-1.
-- Untarring the new sourcecode archive ../texmacs_1.0.6.10.orig.tar.gz
Success! The diffs from version 1:1.0.6.9-4 worked fine.
Remember: Your current directory is the OLD sourcearchive!
Do a "cd ../texmacs-1.0.6.10" to see the new package
$cd ..
$rm -rf texmacs-1.0.6.9/

Update the changelog and do other necessary stuff

$cd texmacs-1.0.6.10/debian/
$dch
...
$cd ..
...

Build the package. The final packages will be in ~/pbuilder/result

$pdebuild-sid
$cd ~/pbuilder/result
$ls texmacs*1.0.6.10*
texmacs_1.0.6.10-1.diff.gz texmacs_1.0.6.10-1_i386.changes texmacs_1.0.6.10.orig.tar.gz
texmacs_1.0.6.10-1.dsc texmacs_1.0.6.10-1_i386.deb texmacs-common_1.0.6.10-1_all.deb
$linda texmacs_1.0.6.10-1.dsc
$lintian texmacs_1.0.6.10-1.dsc

Tuesday, April 24, 2007

gnuplot with GNU readline and history support

By default, the gnuplot packages in Debian are not built with libreadline (GNU readline). This is due to licensing issues (see /usr/share/doc/gnuplot/README.Debian for more info). Having the libreadline support is useful as it enables tab completion of file names inside gnuplot. Using GNU readline, one can also access the commands used in previous gnuplot sessions. The recipe for recompiling the gnuplot packages (in the Debian way) with support for GNU readline and history file is given below.


$cat ~/makefiles/gnuplot.install
#add the following or similar entry into the /etc/apt/sources.list
deb-src http://ftp.us.debian.org/debian/ etch main contrib non-free
# other possible entries look like
# deb-src http://ftp.us.debian.org/debian/ unstable main contrib non-free

# install packages necessary for building gnuplot
sudo apt-get install fakeroot
sudo apt-get build-dep gnuplot
# see the versions of gnuplot available
rmadison gnuplot
# I decided to use gnuplot 4.0.0-5

# go to the place where you normally compile packages
cd /home/software/compileHere/gnuplot

# (optional) move files from previous versions/compilations if they exist
# mv gnuplot-4.0.0/ /tmp
# (optional) move old binary deb files also if necessary
# mv gnuplot*deb /tmp

apt-get source gnuplot=4.0.0-5
dpkg-source -x gnuplot_4.0.0-5.dsc
cd gnuplot-4.0.0/debian/

# Edit the file named "rules" and change
--without-gnu-readline
TO
--with-readline=gnu

# Enable the history file by adding
--enable-history-file

cd ..
dpkg-buildpackage -us -uc -rfakeroot
cd ..

ls gnuplot*deb
gnuplot_4.0.0-5_all.deb gnuplot-nox_4.0.0-5_i386.deb
gnuplot-doc_4.0.0-5_all.deb gnuplot-x11_4.0.0-5_i386.deb

sudo dpkg -i gnuplot*deb

apt-cache showsrc gnuplot

Friday, April 20, 2007

calculate md5sums in windows

A free, open source software called winMd5Sum is available from http://nullriver.com/winmd5sum . This software can be used to compute md5sum values of files.


tested on : Windows XP

Followers