Tuesday 17 January 2012

Post Office Protocol (POP)


POP3 Protocol:


The POP (Post Office Protocol 3) protocol provides a simple, standardized way for users to access  mailboxes and download messages to their computers.                                                     

When using the POP protocol all your eMail messages will be downloaded from the mail server to your local computer. You can choose to leave copies of your eMails on the server as well. The advantage is that once your messages are downloaded you can cut the internet connection and read your eMail at your leisure without incuring further communication costs.

Doing things counts far better than just learning..

lets try it from our terminal to retrieve mails..

Do the following in your terminal to retrieve your mails

*   openssl s_client -connect pop.gmail.com:995

This will open up the coonection

*  user  <username>
*  pass <password>

It will get in to your mail box.

*  list

list command will list all your mails and its  size..

*  retr <msg no>

Will display the particular message from your dropbox

*  top <msgno> <no.of.lines>

This will display the particular message with no of lines you mentioned

*  dele <msg no>

Will delete the message you mentioned

*  quit

Will close the session

Tuesday 10 January 2012

Get Started with apache

We had a good session on apache by our senior Mr.arwin. Here are some things on what we discussed on the session.


Apache:
 
   Apache is a freely available (http) web server.The work of apache is that to create a open source http server that runs on all the operating systems..

The main task of a Web server is to translate a request into a response suitable for the circumstances at the time. When the client opens communication with Apache, it sends Apache a request for a resource. Apache either provides that resource or provides an alternative response to explain why the request couldn’t be fulfilled. In many cases, the resource is a Hypertext Markup Language (HTML) Web page residing on a local disk, but this is only the simplest option. It can be many other things, too—an image file, the result of a script that generates HTML output, a Java applet that’s downloaded and run by the client, and so on.



Here we go:


*In linux you can install apache using the following conmmand
         sudo apt-get install apache2


*Then netstat it (ie.netstat is a network statistics)that will give the incoming ang outgoing connections using netstat -pan |grep apache


*This will show only a non own process do a sudo command so that u can view all the process.


*This will show a details like port,ipaddress and listen etc


*Then find where the apache is using the command  $whereis apache2


*From here u can go the folder of where apache is..


*apache -V will give all the compiled contents of  server including the root and config


*From the given path in the list u can go to the config file and view it


FOR CREATING A NEW MODULE:   


*You can also create anew module by installing the 
               sudo apt-get install apache2-prefork-dev


*After installing  you are ready to create a module using command 
                     sudo apxs2 -g -n "module name"


*The module files will be created


*From there go to the module folder and view the .c file 
            sudo vi mod_filename.c


*You can make changes over this files and save it


*we have to compile this file using the command
           sudo apxs2 -c -i "mod_filename.c"


*Then go the .c file and copy the load file with the locationand paste it in the apache2.conf wat we see earlier


*Paste it in the Apache2.conf


*After pasting restart the apache with the command
           sudo apachectl restart




Hope it  helped a bit to get started  with apache..

Friday 6 January 2012

Screen scraping....

I just get the impact of this screen scraping from my trainer Mr.Kamesh and it was a good one. 

Scraping:

Screen scraping is a process of extracting the data from the webpage and its a technique in which a computer program extracts a data from a website we want.

Some its too good to retrieve data from our favourite website with out CTRL+c and CTRL+v
to view the data we want to see..

So i just tried it with a program in python language.i tried to retrive the name of the candidate who recently placed from our college..

my target url:www.saec.ac.in

I scraped the data is that the person who get placed in our college from M.B.A department.
and finally i end up the code that gives me the result.

import urllib
import re
import string

url = 'http://saec.ac.in/campus/lcube.html'
response = urllib.urlopen(url)
content = response.read()
start=string.index(content,"<table")
stop=string.index(content,"</table")
content = content[start:stop]
start=string.index(content,"</tr")
content = content[start+4:]
start=string.index(content,"<tr")
stop=string.index(content,"</tr")
content = content[start:stop]
for field in re.findall('>([^<]+)<',content):
    print field.replace('\n ',''),

just tried a bit of scraping over here..and im working on top of it to scrap a bulk data.  

 

Tuesday 27 December 2011

Screens on linux.


In our training session on screens by  mr.kamesh. He teaches us the way to switch to different screens..
this is actually a very cool session to know the tricky things in screens.after these sessions we search about this in google and we come to know even more shortcuts to play with that i just share that here..

Screens

Screen is a terminal  multiplexer that allows us to manage many process through one terminal.By that each process gets its own virtual window.so that we can switch between windows..

Interacting with Screens.

Before we get start interacting with screens..we are suppose to know how to open and switch to different windows..

If you want  to play with the screens just try the following keys in the terminal.

To open a new screen: Type screen

It will enter in to the screen after that u can open a new window using

Ctrl+a c: open a new screen

Ctrl+a n: next screen

Ctrl+a p: previous screen

Ctrl+a ": select the windows from the list  (Try this is good one)

Ctrl+a  S: split terminal horizontally into region

Ctrl+a |: split terminal vertically into regions

Ctrl+a :resize resize region  

Ctrl+a :fit fit screen size to new terminal size Ctrl+a F is the same. Do after resizing xterm

Ctrl+a :remove remove region Ctrl+a X is the same

Ctrl+a tab Move to next region  
   
Ctrl+a d: detach screen from terminal Start screen with -r option to reattach

Ctrl+a A: set window title  

Ctrl+a x: lock session Enter user password to unlock

Ctrl+a [: enter scrollback/copy mode Enter to start and end copy region. Ctrl+a ] to leave this mode

Ctrl+a ]: paste buffer Supports pasting between windows

Ctrl+a >: write paste buffer to file useful for copying between screens

Ctrl+a <: read paste buffer from file useful for pasting between screens
   
Ctrl+a ?: show key bindings/command names Note unbound commands only in man page

Ctrl+a : goto screen command prompt up shows last command entered


Just enjoy playing with screens..


Monday 26 December 2011

session on ltrace and strace in linux


We had a very nice session about these ltrace and strace in linux commands by mr.vijay guru..
let me share certain things on those topics here..

Before we getting in to the topic.we first see the unix architecture..


This architecture helps us to know how the system and library calls reach the kernel and get the response..
as we are going deep in to the topic the question nudges our mind how the calls from our application reaches the kernel of the os and respond back to us..


This is how the directions of calls have requested and responded to the commands..


ltrace- A library call tracer.
strace-A system call tracer.

ltrace is a debugging utility in linux to monitor the library calls used by a program and all the signals it receives. It can also show system calls, used by a program.
ltrace [-CdfhiLrStttV] [-a column] [-e expr] [-l filename] [-n nr] [-o filename] [-p pid] ... [-s strsize] [-u username] [-X extern] [-x extern] ... [--align=column] [--debug] [--demangle] [--help] [--indent=nr] [--library=filename] [--output=filename] [--version] [command [arg ...]]


starce is a tool which enables tracing the System calls made by a process during its execution. It also reports the signals that are recieved by the process.

According to the Linux manual page, in the simplest case 'strace runs the specified command until it exits. It intercepts and records the system calls which are called by a process and the signals which are received by a process. .


$strace
usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] ... [-o file] [-p pid] ... [-s strsize] [-u username] [-E var=val] ... [command [arg ...]] or: strace -c [-e expr] ... [-O overhead] [-S sortby] [-E var=val] ... [command [arg ...]] -c -- count time, calls, and errors for each syscall and report summary

here i just show u screenshot of strace..





Tuesday 20 December 2011

Its great to know about SMTP

We all are handling with loads of emails..But we are not aware of things happening behind. This Simple Mail Transfer Protocol (SMTP) is an Internet Standard email transmission across Internet Protocol (IP) networks. 


Let us know what exactly happens when we send emails. client applications usually use either the Post Office Protocol (POP) or the Internet Message Access Protocol (IMAP) on a proprietary system (such as Microsoft Outlook or Thunderbird) to access their mail box accounts on a mail server. As ”Picture speaks far more than words” we’ll deal this with a picture. 





  • MUA(Mail User Agent) 
  • MSA(Mail Submission Agent) 
  • MTA(Mail Transfer Agent) 
  • MDA(Mail Delivery Agent) 



From the above picture we can clearly arrive at how stuff works behind the email servers.

Our email client will act as the MUA’s.when we send the mails it searches for the MSA and this submits the mail to the MTA.This MTA is playing a very vital role in  transferring the mail to the MDA.Thereafter the mails are finally drop into the receiver’s mail box.




When we compose a message and press the Send button, here's what happens:

1. Outlook Express connects to the SMTP server at mail.yahoo.com using port 25.

2. Outlook Express has a conversation with the SMTP server, telling the SMTP server the address of the sender and the address of the recipient, as well as the body of the message.

3. The SMTP server takes the "to" address (sathish@yahoo.com) and breaks it into two parts: the recipient name (sathish) and the domain name (yahoo.com). If the "to" address had been another user at yahoo.com, the SMTP server would simply hand the message to the POP3 server for yahoo.com (using a little program called the delivery agent). Since the recipient is at another domain, SMTP needs to communicate with that domain.

4. The SMTP server has a conversation with a Domain Name Server, or DNS .It says, "Can you give me the IP address of the SMTP server for yahoo or gmail. The DNS replies with the one or more IP addresses for the SMTP server(s) that Server operates.

5. The SMTP server at yahoo.com connects with the SMTP server at gmail using port 25. It has the same simple text conversation that my e-mail client had with the SMTP server for Yahoo, and gives the message to the gmail The google server recognizes that the domain name for sathish is at , so it hands the message to gmail’s POP3 server, which puts the message in receipient mailbox.

If, for some reason, the SMTP server at Yahoo cannot connect with the SMTP server at Gmail, then the message goes into a queue. The SMTP server on most machines uses a program called sendmail to do the actual sending, so this queue is called the sendmail queue. Sendmail will periodically try to resend the messages in its queue. For example, it might retry every 15 minutes. After four hours, it will usually send you a piece of mail that tells you there is some sort of problem. After five days, most sendmail configurations give up and return the mail to you undelivered.


The SMTP server understands very simple text commands like HELO, MAIL, RCPT and DATA. The most common commands are:

· HELO - introduce yourself

· EHLO - introduce yourself and request extended mode

· MAIL FROM: - specify the sender

· RCPT TO: - specify the recipient

· DATA - specify the body of the message (To, From and Subject should be the first three lines.)

· RSET - reset

· QUIT - quit the session

· HELP - get help on commands

· VRFY - verify an address

· EXPN - expand an address

· VERB - verbose

If your very curious to try it from your terminal.follow the steps to do so.





MY FIRST POST

Hi all..this is my first post in my blog.I thought of sharing my exposure in field of computer science probably to all my friends.. This is the first idea that nudges in my mind.So from here you can feel the impact...