Wednesday, April 30, 2014

Connecting to wifi access point from the terminal

The following process has worked for me. I simply followed the procedure mentioned in arch linux wiki with a small tip from one of their forum post. So, a big thanks to the Arch community.

First of all, I am assuming all the wireless drivers are installed and loaded properly. I used the commands: iw, ip, wpa_supplicant for the process. NetworkManager was not used.

 $ iw dev  
   phy#0  
     Interface wlan0  
     ifindex 3  
     type managed  

This gives me the name of the wireless interface: wlan0

 $ ip link show  
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN   
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000  
   link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff  
 3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000  
   link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff  

That means my wireless link wlan0 was not UP (otherwise the word UP would be there within <>)

 $ sudo ip link set wlan0 up  
 $ ip link show  
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN  
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00  
 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000  
   link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff  
 3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN qlen 1000  
   link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff  

Now, the wlan0 is UP. So, now it is time to find out what access points are available.

 $ sudo iw dev wlan0 scan | grep SSID  
     SSID: TP-LINK_POCKET_3020_C50F1E  
     SSID: Ramananda  

Ok. I want to connect to the first one. But before that I need to create a wpa_supplicant.conf file with the SSID and Password for the Access Point to which I want to connect.

 $ wpa_passphrase TP-LINK_POCKET_3020_C50F1E xxxxxxxx > wpa_supplicant.conf  

Now that the wpa_supplicant.conf file is generated, I can attempt to connect to the access point.

 $ sudo wpa_supplicant -iwlan0 -c wpa_supplicant.conf  
 ioctl[SIOCSIWENCODEEXT]: Invalid argument  
 ioctl[SIOCSIWENCODEEXT]: Invalid argument  
 Trying to associate with xx:xx:xx:xx:xx:xx (SSID='TP-LINK_POCKET_3020_C50F1E' freq=2462 MHz)  
 Associated with xx:xx:xx:xx:xx:xx  
 WPA: Key negotiation completed with xx:xx:xx:xx:xx:xx [PTK=CCMP GTK=CCMP]  
 CTRL-EVENT-CONNECTED - Connection to xx:xx:xx:xx:xx:xx completed (auth) [id=0 id_str=]  

I don't know about the ioctl lines, but now I am connected to the wireless access point. Now what I need to do is to use dhclient3 or dhcpcd to get an ip address from my access point (which is also configured as a dhcp server)

 $ sudo dhclient3 wlan0  

Done. Now I can successfully ping google :-)

Dear Inconsolata, I want to use you properly

I never got why inconsolata font is considered good for coding and things like that... until today.

I learnt that if I set autohint=true for the Inconsolata font in Linux (I am currently on Ubuntu 14.04), it actually looks great!

So, after reading some portions of the fonts.conf(5) manual page, I added the following stanza to my .config/fontconfig/fonts.conf file so that autohinting will be selectively turned on only for the Inconsolata font (others fonts tend to look horrible if autohinting is turned on as far as I am concerned):

 <match target="pattern">
     <test name="family">
         <string>Inconsolata</string>
     </test>
     <edit mode="assign" name="autohint">
         <bool>true</bool>
     </edit>
 </match>


Monday, February 10, 2014

Getting the correct pre-requisites for building gcc


Today I had to build a gcc cross compiler for my OS related experiments (I was building the bare bone OS as described in http://wiki.osdev.org/Bare_Bones). For some reason, gcc would not build. Turned out the versions of mpc, mpfr and gmp that I downloaded were likely not compatible, and were causing problems.

After some searching on the net I found that inside gcc source tree, there is a folder called contrib which contains a script called download_prerequisites. So, all I needed to do was to get into gcc source folder and execute:

$ ./contrib/download_prerequisites.

This downloaded the correct versions of the prerequisites and I was then able to successfully build the i586-elf target gcc cross compiler.


Thursday, January 2, 2014

An excellent source of some nice tutorials

Today, I was looking for some nice tutorial videos on intel assmbly language, and found this:
http://opensecuritytraining.info/IntroX86.html

Very informative.

I think I am going to frequently visit this site for their nice tutorials on some interesting topics which I find interesting.

Monday, December 30, 2013

Sample usage of transcoding using vlc, then genisoimage and wodim to write a dvd

Today I needed to write a dvd with some old family videos in it. The videos were obtained from my Sony Handycam. They were .MPG files, but the problem was they were too large to fit in a dvd.

So, to reduce their size without changing the quality, I decided to transcode them using vlc. I had no idea how to do it. So I fired up vlc from a terminal and after exploring some menu items, I transcoded one of the files to .mp4. The size got reduced by more than half. Great! Now I had to find a corresponding command line form of the same action for automating it for transcoding all of the 36 files I had.

So, I looked at the terminal dump of whatever vlc had done so far, and then googled around a little, and came up with this solution (for my case):

for i in `seq -w 01 36`; do 
  cvlc ~/Videos/HomeVideos/2011.10.05/M2U000$i.MPG
       --sout '#transcode{
                  vcodec=h264,vb=0,scale=0,
                  acodec=mpga,ab=128,
                  channels=2,samplerate=44100
               }:std{access=file,mux=mp4,dst='./$i.mp4'}'
       vlc://quit;
done


(BTW, what I actually ran was the above code all in a single loong line. I just formatted the above code to look nice and be more understandable. I am not sure whether the code would work if formatted like above. Too lazy to try now.)

The vlc://quit was to make vlc quit after transcoding each file. Otherwise I had to press Ctrl-C after each file was transcoded.

Next I made an iso image out of the transcoded files with the genisoimage as follows:

genisoimage -o homevideos_2011.10.05.iso \
            -p "Santanu" -V "HomeVideos_2011.10.05" -publisher "Santanu" \
            ./converted/


Then I wrote the resulting iso file to a blank dvd using wodim as follows:

wodim -v -eject speed=4 dev=/dev/dvdrw driveropts=burnfree homevideos.iso