Monday, February 11, 2019

Python: BMI calculation using dict of lists

bmi=dict()

while True:
   name=input('Enter a name:')
   bmi[name]=[float(input('Enter weight in kgs:')),float(input('Height in feet:'))*0.3048]    
   bmi[name].insert(0,(bmi[name][0]/(bmi[name][1]**2)))
   opt=input('Do you want to add more names(input y/n):')
   if opt in ('N','n'):
      break   print()

for k,v in bmi.items():
   print(f"The BMI of {k} is {v[0]} and falls under category of:",end=' ')
   if (0 < v[0] <15):
      print("Very serverely underweight")
   elif (15 <= v[0] <16):
      print("Severely underweight")
   elif (16 <= v[0] < 18.5):
      print("Underweight")
   elif (18.5 <= v[0] < 25):
      print("Normal (Healthy Weight)")
   elif (25 <= v[0] < 30):
      print("Overweight")
   elif (30 <= v[0] < 35):
      print("Obese Class I (Moderately obese)")
   elif (35 <= v[0] < 40):
      print("Obese Class II (Severely obese)")
   elif (40 <= v[0]):
      print("Obese Class III (Very Severely Obese)")
   else:
      print("Done")

print()
print('\t'*2,'*'*10,'SUMMARY','*'*10)
print()

print("Names with lower BMI:",[l for l in bmi.keys() if (bmi[l][0]<18.5)])
print("Names with Normal BMI:",[l for l in bmi.keys() if (18.5<=bmi[l][0]<=25)])
print("Names with higher BMI:",[l for l in bmi.keys() if (bmi[l][0]>25)])

print() 

print("The number of individuals with lower BMI :",len([l for l in bmi.keys() if (bmi[l][0]<18.5)]))
print("The number of individuals with normal BMI :",len([l for l in bmi.keys() if (18.5<=bmi[l][0]<=25)]))
print("The number of individuals with higher BMI :",len([l for l in bmi.keys() if (bmi[l][0]>25)]))

print() 

print("The lowest BMI is:",min([bmi[l][0] for l in bmi.keys()]))
print("The Average BMI is:",sum([bmi[l][0] for l in bmi.keys()])/len([l for l in bmi.keys()]))
print("The maximun BMI is:",max([bmi[l][0] for l in bmi.keys()]))




Example:

% python funcbmi.py

Enter a name:Allen
Enter weight in kgs:78
Height in feet:5.6
Do you want to add more names(input y/n):y
Enter a name:Helen
Enter weight in kgs:45
Height in feet:5.
Do you want to add more names(input y/n):y
Enter a name:Alice
Enter weight in kgs:85
Height in feet:5.8
Do you want to add more names(input y/n):y
Enter a name:Steve
Enter weight in kgs:40
Height in feet:4
Do you want to add more names(input y/n):n

The BMI of Allen is 26.772481266050967 and falls under category of: Overweight
The BMI of Helen is 19.375038750077497 and falls under category of: Normal (Healthy Weight)
The BMI of Alice is 27.19775224198354 and falls under category of: Overweight
The BMI of Steve is 26.909776041774304 and falls under category of: Overweight

                 ********** SUMMARY **********

Names with lower BMI: []
Names with Normal BMI: ['Helen']
Names with higher BMI: ['Allen', 'Alice', 'Steve']

The number of individuals with lower BMI : 0
The number of individuals with normal BMI : 1
The number of individuals with higher BMI : 3

The lowest BMI is: 19.375038750077497
The Average BMI is: 25.063762074971578
The maximun BMI is: 27.19775224198354

Thursday, March 22, 2018

Check commit status

This summary is not available. Please click here to view the post.

Get Release Notes

#!/bin/sh -x

export SVNROOT=svn+ssh://svn.xxx.com/svn

if [ $1 == "--help" ]
then
   echo -e "This script fetches the NEWS file updates between two release tags \n";
   echo -e "Checkout the release workspace with make-toad-x.y.x-workspace.sh script";
   echo -e "Execute release_notes.sh script in the directory";
   echo -e "Usage: release_notes.sh TAG1 TAG2 \n";
   echo -e "Example:\n mkdir temp_dir1 \n cd temp_dir1 \n ./make-toad-3.12.2-workspace.sh\n release_notes.sh  3.12.2.6 3.12.2.0 \n NEWS_update.log has the NEWS file updates \n";
   exit;
fi

if [ $# == 0 ]  || [ $# -ne 2 ]
then
   echo -e "Please input the valid release tags as arguments.";
   exit;
fi

build_version1=`echo $1 | awk -F. '{print $4}' `;
build_version2=`echo $2 | awk -F. '{print $4}' `;

if [ -f NEWS_update.log ]
then
   rm -f NEWS_update.log
fi

for i in `find . -maxdepth 1 -type d | sed 's/\.\///g' | sed 's/\.//g'`
do
  cd $i;
  rel_branch=`svn info | head -2 | tail -1 | awk -F/ '{print $8}' | sed -e 's/VERSION_//g' | sed -s 's/_/./g'`;
  TAG1=$rel_branch.$build_version1;
  TAG2=$rel_branch.$build_version2;
  echo -e "$i:" >> ../NEWS_update.log;
  echo -e "---------------- \n" >> ../NEWS_update.log;
  sed -n '/Shipped in '$TAG1'/,/Shipped in '$TAG2'/{ /Shipped in '$TAG1'/d; /Shipped in '$TAG2'/d; p; }' NEWS >> ../NEWS_update.log;
  echo -e "\n" >> ../NEWS_update.log;
  cd ../;
done
echo -e "NEWS_update.log has release notes";

Wednesday, July 20, 2016

Difference between awk and cut command?

cut:  takes a single character in -d as the field delimiter (the default being TAB), and every single occurrence of that character starts a new field. 



awk:  however, is more flexible. The separator is in the FS variable and can be an empty string (every input character makes a separate field), a single character, or a regular expression. The special case of a single space character (the default) means to split on any sequence of whitespace. Also, awk suppresses leading whitespace by default.

Examples: 

% echo "All is well" | cut -f 2 -d ' '
is

%echo "All  is  well" | cut -f 2 -d ' '


% echo " All is well" | cut -f 2 -d ' '
All


% echo "All is well" | awk '{print $2}'
is

% echo "All  is  well" |  awk '{print $2}'
is

% echo " All is well" | awk '{print $2}'
is





How to check if a port is occupied or not?


Monday, July 18, 2016

Difference between the perl functions: chop and chomp?

chomp: Deletes only new line character "$/   (or) \n" (input record separator or new line character) at                the end of the line.


chop: Deletes the last character irrespective what it is.

Tuesday, May 12, 2015

Write a program to compare two files A and B and report the following: lines present in both files A and B = A U B, lines common to both A and B = A & B, lines present in A but not B = A - B, lines present in B but not in A = B - A.

#!/usr/local/bin/perl

##Script to compare 2 NEWS files
## Generates 3 files
## FILE_1_only: This file contains lines present only in first file
## FILE_2_only: This file contains lines present only in second file
## FILE1_2: This file contains lines common to both files

use strict;
use warnings;

my %hash1;
my %hash2;

##Use Tie module to process the hash in the insertion order ###
use Tie::IxHash;
tie %hash1, "Tie::IxHash";
tie %hash2, "Tie::IxHash";

###trim any leading or trailing spaces####
#sub rtrim { my $s = shift; $s =~ s/\s+$//; return $s };
sub trim { my $s = shift; $s =~ s/^\s+//; $s =~ s/\s+$//; return $s };

if(@ARGV != 2) {
        print "Please pass the files to be compared as command line arguments \n";
        print "Usage: $0 file1 file2 \n";
        print "Ex: $0 NEWS_5_0_1 NEWS_3_15_0 \n";
        print "O/P: FILE_1_only, FILE_2_only and FILE1_2 \n";
}

open (FH1, "<$ARGV[0]") or die "Couldnot open file $ARGV[0], $!";
open (FH2, "<$ARGV[1]") or die "Couldnot open file $ARGV[1], $!";
open (FH3, ">FILE1_2");
open (FH4, ">FILE_1_only");
open (FH5, ">FILE_2_only");

my @arr1=<FH1>;
my @arr2=<FH2>;

foreach my $l (@arr1) {
      chomp($l);
      $hash1{trim($l)}++;
}


foreach my $m (@arr2) {
      chomp($m);
      $hash2{trim($m)}++;
}

foreach my $k1 (keys %hash1) {
        if($hash2{$k1}) {
                print FH3 $k1;
                print FH3 "\n";
        } else {
                print FH4 $k1;
                print FH4 "\n";
        }
}

foreach my $k2 (keys %hash2) {
        if (!$hash1{$k2}) {
                print FH5 $k2;
                print FH5 "\n";
        }
}




Usage: ./compare_NEWS.pl NEWS_5.0.1 NEWS_3.15.0

O/P:
FILE_1_only: This file contains lines present only in first file
FILE_2_only: This file contains lines present only in second file
FILE1_2: This file contains lines common to both files

Write a program to accept username and password as input arguments without displaying the password.

#!/bin/bash

unset PASSWORD
unset CHARCOUNT

echo -n "Login:";
read login_name;
echo -n "Enter password: "

stty -echo

CHARCOUNT=0
while IFS= read -p "$PROMPT" -r -s -n 1 CHAR
do
    # Enter - accept password
     if [[ $CHAR == $'\0' ]] ; then
         break
     fi
     # Backspace
     if [[ $CHAR == $'\177' ]] ; then
         if [ $CHARCOUNT -gt 0 ] ; then
            CHARCOUNT=$((CHARCOUNT-1))
            PROMPT=$'\b \b'
            PASSWORD="${PASSWORD%?}"
         else
            PROMPT=''
         fi
     else
         CHARCOUNT=$((CHARCOUNT+1))
         PROMPT='*'
         PASSWORD+="$CHAR"
     fi
done
stty echo

if [[ $login_name == "pearl"  && $PASSWORD == "pearlyperl" ]] ; then
    echo -e "\n Login Successful  :-)  \n";
else
    echo -e "Login Failed \n";
fi


OUPUT:

./login.sh
Login:pearl
Enter password: **********
Login Successful :-)

Write a perl program to read username and password from user without displaying the password string.

#!/usr/local/bin/perl

use strict;
use warnings;

print "Please enter you credentials \n";
print "login:";
my $usr_nm = <STDIN>;
print "password:";
system('stty', '-echo');
my $pswd = <>;
system('stty', 'echo');
print "\n";




Output:
./login.pl
Please enter you credentials
login:user_name
password:

File the frequency of each word and print the output in the decreasing order

#!/usr/local/bin/perl

use strict;
use warnings;
my %count;
my $file = shift or die "Usage: $0 FILE\n";
open my $fh, '<', $file or die "Could not open '$file' $!";
while (my $line = <$fh>) {
        chomp $line;
        foreach my $str (split /\s+/, $line) {
             $count{$str}++;
        }
}

foreach my $str (reverse sort {$count{$a} <=> $count{$b}} keys %count) {
        printf "%-31s %s\n", $str, $count{$str};
}



USAGE: ./count.pl  txt1

OUTPUT:
are                               3
you                              3
Hii                               2
how                             2
hii                                2
i                                   1
Hoe                             1
am                               1
doing                           1
well                             1


Aptitude Question: Find the shortest distance travelled by a ant on the side of the cube to reach from A to H?












































The minimum distance travelled by ant to reach from A to H is = square root of 5 = 2.326

Sunday, May 10, 2015

What is @INC in perl?

The @INC array is a list of directories Perl searches when attempting to load modules. To display the current contents of the @INC array:

perl -e 'print @INC '

The following two methods may be used to append to Perl's @INC array:

1. Add the directory to the PERL5LIB environment variable.
2. Add use lib 'directory'; in your Perl script.

Installing latest version of python on CentOS 5

http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source

The latest release of the python scripting language is Python 3.2. However due to backwards incompatibilities with Python 2, it has not been adopted for CentOS / Redhat Linux 5. T he primary reason for this, is because release of 'yum' (package management) used in EL5 requires Python 2. Because of this, Python cannot be upgraded in place to version 3 without breaking the package manager.
Therefore to use Python 3, it will need to be installed outside of /usr.

Installing

Below is the list of command (with inline comments) on what is required to compile and install Python 3 from source. The installation will be done into the prefix /opt/python3. This will ensure the installation does not conflict with system software installed into /usr.
# Install required build dependencies
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

# Fetch and extract source. Please refer to http://www.python.org/download/releases
# to ensure the latest source is used.
wget http://www.python.org/ftp/python/3.2/Python-3.2.tar.bz2
tar -xjf Python-3.2.tar.bz2
cd Python-3.2

# Configure the build with a prefix (install dir) of /opt/python3, compile, and install.
./configure --prefix=/opt/python3
make
sudo make install
Python 3 will now be installed to /opt/python3.
$ /opt/python3/bin/python3 -V
Python 3.2
Ensure your python 3 scripts and applications query the correct interpreter.
#!/opt/python3/bin/python3

Wednesday, June 8, 2011

How to install scmbug?

scmbug: is a system that integrates software configuration management (SCM) with bug-tracking.


Download: smbug software can be downloaded from http://www.mkgnu.net/scmbug_download   ( it has both rpm and debian packages).

Manual:  http://files.mkgnu.net/files/scmbug/doc/latest_manual/html-multi/index.html


Steps:

login to a i386 / i686 unix machine

Download the stable version of debian / rpm packages from the link :
Debians:  http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/ 

Rpms's: http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/rpms/


% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug-common_0.26.22_all.deb"

% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug-doc_0.26.22_all.deb"

% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug-server_0.26.22_all.deb"

% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug-tools_0.26.22_all.deb"

% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug_0.26.22.dsc"

% wget "http://files.mkgnu.net/files/scmbug/SCMBUG_RELEASE_0-26-22/debs/scmbug_0.26.22_i386.changes"

Friday, February 25, 2011

How to Download and install HUDSON on linux?

HUDSON:

Hudson monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Hudson focuses on the following two jobs:
  1. Building/testing software projects continuously, just like CruiseControl or DamageControl. In a nutshell, Hudson provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.
  2. Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that are run on a remote machine. For example, with cron, all you receive is regular e-mails that capture the output, and it is up to you to look at them diligently and notice when it broke. Hudson keeps those outputs and makes it easy for you to notice when something is wrong.
 Continuous Integration with automated test execution has seen broad adoption in recent years. The ideas behind Continuous Integration have changed how companies look at Build Management, Release Management, Deployment Automation, and Test Orchestration. This section provides a set of best practices for Hudson - A Continuous Integration Solution to provide executives, business managers, software developers and architects a better sense of the development progress and code quality of projects throughout the development lifecycle.


HUDSON Home page:  http://wiki.hudson-ci.org/

 Download HUDSON:


$ ls

-rw-r--r-- 1 root root 27936319 2010-06-01 12:30 hudson-1.340-1.1.noarch.rpm

Install a rpm package: (man rpm)

% rpm –ivh hudson-1.340-1.1.noarch.rpm   (“-I” – install, "-v" – Verbose, "-h" - Print 50 hash marks as the package  archive  is  unpacked.   Use with -v|--verbose for a nicer display)

% rpm –qa    (will list down all the installed rpm packages on a machine.)

% adduser -m -s /bin/bash  Hudson

% startup.sh

+ JAVA=/usr/java
+ /etc/init.d/hudson start
Starting Hudson -bash: /usr/bin/java: No such file or directory
                                                           [FAILED]

Installing Java on linux:


Select the correct operating system compatiable file and download it:

% mkdir /usr/bin/java
% cd /usr/bin/java
% chmod a+x ./jre*
% ./jre*

% rpm –qa | grep jre

jre-1.6.0_24-fcs

% rpm -ql  jre-1.6.0_24-fcs  (Check the package related files using the command)

/usr/java/jre1.6.0_24/*

It means the package is installed at “/usr/java/jre1.6.0_24/”


Firefox or Mozilla

To configure the Java Plugin follow these steps:

1.       Exit Firefox browser if it is already running.
2.       Uninstall any previous installations of Java Plugin.
Only one Java Plugin can be used at a time. When you want to use a different plugin, or version of a plugin, remove the symbolic links to any other versions and create a fresh symbolic link to the new one.
3.       Create a symbolic link to the libnpjp2.so file in the browser plugins directory
·         Go to the plugins sub-directory under the Firefox installation directory
cd <Firefox installation directory>/plugins
·         Create the symbolic link
ln -s <Java installation directory>/lib/i386/libnpjp2.so



Example
·         If Firefox is installed at this directory:
/usr/lib/<Firefox installation directory>
·         And if the Java is installed at this directory:
/usr/java/<Java installation directory>
·         Then type in the terminal window to go to the browser plug-in directory:
/usr/lib/<Firefox installation directory>/plugin
·         Enter the following command to create a symbolic link to the Java Plug-in for the Mozilla browser.
ln -s /usr/java/<Java installation directory>/lib/i386/libnpjp2.so



4.       Start the Firefox browser, or restart it if it is already up. 

In Firefox, type about:plugins in the Location bar to confirm that the Java Plugin is loaded. You can also click the Tools menu to confirm that Java Console is there.



% Cat startup.sh

#!/bin/sh -x

JAVA=/usr/java

/etc/init.d/hudson start


% ln -sf  /usr/java/latest/bin/java /usr/bin/java

./startup.sh
+ JAVA=/usr/java
+ /etc/init.d/hudson start
Starting Hudson                                            [  OK  ]

%  ps -ef | grep Hudson

hudson   15696     1 12 14:20 ?        00:00:06 /usr/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20




How to view the HUDSON home page:

Open firefox browser and type the following in the address tab: http://localhost:port/


Thursday, February 24, 2011

How to install Sub Version (SVN) on a linux machine?


Topics

1.1   Subversion
1.2   Install subversion on a linux machine
1.2.1          Download the svn source code
1.2.2          Determine the dependencies
1.2.3          To install apr and apr-utils
1.2.3.1    Build and install apr
1.2.3.2    Build and install apr-utils
1.2.4           Build and install subversion
1.3   Subversion server
1.3.1          Apache server
1.3.2          Svnserve server
1.3.2.1    Invoking the server
1.4   Create a repository
1.5   Add / Import files to repository
1.5.1          To list all the files in the repository
1.5.2          Check the log of a file in the repository
1.6   Importing a project with bunch of files in a specific directory structure
1.7   Checking out a project
1.8   Editing and adding files
1.9   Committing the changes into the repository
2. Versioning in svn
3.  References






















1.1 Subversion
Subversion is a free/open source version control system. That is, Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine.
Subversion can operate across networks, which allows it to be used by people on different computers. At some level, the ability for various people to modify and manage the same set of data from their respective locations fosters collaboration. Progress can occur more quickly without a single conduit through which all modifications must occur. And because the work is versioned, you need not fear that quality is the trade-off for losing that conduit—if some incorrect change is made to the data, just undo that change.
Some version control systems are also software configuration management (SCM) systems. These systems are specifically tailored to manage trees of source code and have many features that are specific to software development—such as natively understanding programming languages, or supplying tools for building software. Subversion, however, is not one of these systems. It is a general system that can be used to manage any collection of files. For you, those files might be source code—for others, anything from grocery shopping lists to digital video mix downs and beyond.

1.2 Install subversion on a linux machine

Installing subversion is a pretty easy task. This section covers installing subversion from a source tarball, for client-type uses. This document is based on an install of Subversion-1.6.15.tar.gz, but the install procedure should be similar for other versions as well.

For its functionality, subversion makes use of (depends on) a number or other pieces of software, all of which are also available for free. You must install these pieces of software before installing subversion. In many cases, some or all of the required software will already be installed on your system.

First determine the properties of the linux machine on which subversion has to be installed with the help of uname command.

$ uname –a

Linux machine_name 2.6.23.1-42.fc8 #1 SMP Tue Oct 30 13:55:12 EDT 2007 i686 i686 i386 GNU/Linux

NOTE:
uname (shortname for unix name) is a software program in unix that prints the name, version and other details about the current machine and the operating system running on it.


1.2.1 Download the subversion source code:


If you're looking for downloads of Subversion, visit our Source Code or Packages pages.

Click on Source Code link in the above line it would take you to below link:


Select the latest version of subversion software tar balls i.e 1.6.15 .tar.gz (or)  .tar.bz2 files for linux operating system.

$  wget  "http://subversion.tigris.org/downloads/subversion-1.6.15.tar.bz2"

--16:08:34--  http://subversion.tigris.org/downloads/subversion-1.6.15.tar.bz2
           => `subversion-1.6.15.tar.bz2'
Resolving subversion.tigris.org... 204.16.104.146
Connecting to subversion.tigris.org|204.16.104.146|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5,515,056 (5.3M) [application/x-bzip2]

100%[====================================>] 5,515,056    121.96K/s    ETA 00:00

16:09:33 (92.00 KB/s) - `subversion-1.6.15.tar.bz2' saved [5515056/5515056]


$  ls

-rw-r--r--  1 root root 5515056 2010-11-24 21:38 subversion-1.6.15.tar.bz2

% tar –jxvf subversion-1.6.15.tar.bz2  (Untars the tar.bz2 file and creates all the files under the directory subversion-1.6.15


$ tar -jxvf subversion-1.6.15.tar.bz2


$  ls

-rw-r--r--  1 root root 5515056 2010-11-24 21:38 subversion-1.6.15.tar.bz2
drwxr-xr-x 10 1000 1000    4096 2011-02-15 16:26 subversion-1.6.15


$  cd subversion-1.6.15

$  ls  (lists a no. of files)

$  \vi INSTALL

(This file has the instructions to build and install svn and you will end up with a 'svn' binary in the subversion/svn/subdirectory (or installed in /usr/local/bin/, if you ran 'make install'.)


1.2.2 Determine the dependencies:

For its functionality, subversion makes use of (depends on) a number or other pieces of software, all of which are also available for free. You must install these pieces of software before installing subversion. In many cases, some or all of the required software will already be installed on your system.

On Unix systems, the './configure' script will tell you if you are missing the correct version of any of the required libraries or tools, so if you are in a real hurry to get building, you can skip straight to section II.  If you want to gather the pieces you will need before starting out, however, you should execute the following.

$  ./configure

OUTPUT:

===================================================================================
configure: Configuring Subversion 1.6.15
configure: creating config.nice
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking for a sed that does not truncate output... /bin/sed
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking whether ln -s works... yes
checking for a BSD-compatible install... /usr/bin/install -c
configure: Apache Portable Runtime (APR) library configuration
checking for APR... no
configure: WARNING: APR not found
The Apache Portable Runtime (APR) library cannot be found.
Please install APR on this system and supply the appropriate
--with-apr option to 'configure'

or

get it with SVN and put it in a subdirectory of this source:

   svn co \
    http://svn.apache.org/repos/asf/apr/apr/branches/1.2.x \
    apr

Run that right here in the top level of the Subversion tree.
Afterwards, run apr/buildconf in that subdirectory and
then run configure again here.

Whichever of the above you do, you probably need to do
something similar for apr-util, either providing both
--with-apr and --with-apr-util to 'configure', or
getting both from SVN with:

   svn co \
    http://svn.apache.org/repos/asf/apr/apr-util/branches/1.2.x \
    apr-util

configure: error: no suitable apr found


1.2.3 Install apr and apr-utils
The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predictable and consistent interface to underlying platform-specific implementations. The primary goal is to provide an API to which software developers may code and be assured of predictable if not identical behavior regardless of the platform on which their software is built, relieving them of the need to code special-case conditions to work around or take advantage of platform-specific deficiencies or features.
1.2.3.1  Build and install apr
$ cd /usr/local/src
--16:45:47--  http://www.eng.lsu.edu/mirrors/apache//apr/apr-1.4.2.tar.bz2
           => `apr-1.4.2.tar.bz2'
Resolving www.eng.lsu.edu... 130.39.24.178
Connecting to www.eng.lsu.edu|130.39.24.178|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 766,793 (749K) [application/x-tar]
100%[=================================================================================================================>] 766,793       92.95K/s    ETA 00:00
16:45:58 (79.70 KB/s) - `apr-1.4.2.tar.bz2' saved [766793/766793]% tar -jxvf apr-1.4.2.tar.bz2
$ cd apr-1.4.2
$ ./configure
$ make
$ make install
$ cd /usr/local/bin
$  ln -sf  /usr/local/apr/bin/apr-1-config  apr

1.2.3.2  Build and install the apr-util
$ ls
apr-util-1.3.10.tar.bz2
$ tar -jxvf apr-util-1.3.10.tar.bz2
$ cd  apr-util-1.3.10
$ ./configure --with-apr=/usr/local/apr --with-berkeley-db=/usr/bin
$ make
$ make install
$ cd /usr/local/bin
$ ln -sf  /usr/local/apr/bin/apu-1-config  .
$ mv apu-1-config   apu-1-config-v.1.3.10
$ ln -sf apu-1-config-v.1.3.10 apr-util

1.2.4 Build and install svn
$ cd subversion-1.6.15
$  ./configure --with-apr=/usr/bin/local/apr  --with-apr-util=/usr/bin/local/apr-util
(You need to pass the path of apr and apr-util libraries if it is not able to detect by default and it can be verified with the help of./configure tool)
$  make
$  make install
$ which svn
/usr/local/bin/svn
$ svn  --version
svn, version 1.6.15 (r1038135)
   compiled Feb 16 2011, 12:12:40
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.apache.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).
The following repository access (RA) modules are available:
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

1.3 Subversion Server:
Subversion has two servers you can choose from:  svnserve and Apache.  svnserve is a small, lightweight   server program that is automatically compiled when you build Subversion's source.  Apache is a more heavyweight HTTP server, but tends to have more features.
1.3.1        Apache Server:

1.3.2        Svnserve server:
An alternative network layer is libsvn_ra_svn (on the client side) and the 'svnserve' process on the server.  This is a simple network layer that speaks a custom protocol over plain TCP (documented in libsvn_ra_svn/protocol). Clients contact an svnserve server by using URLs that begin with the svn:// or svn+ssh:// scheme.
The easiest option is to run svnserve as a standalone “daemon”  process. Use the –d option for this:
         $ svnserve -d     # becomes a background daemon
When running svnserve in daemon mode, you can use the --listen-port and --listen-host options to customize the exact port and hostname to “bind” to.
Once we successfully start svnserve as explained previously, it makes every repository on your system available to the network. A client needs to specify an absolutepath in the repository URL. For example, if a repository is located at /var/svn/project1, a client would reach it via svn://host.example.com/var/svn/project1. To increase security, you can pass the -r option to svnserve, which restricts it to exporting only repositories below that path. For example:
          $  svnserve -d -r ~/SVN/depot/projects

         $ svn checkout svn://localhost/usr/local/svn/repository                                                       
You can use the "-r" option to svnserve to set a logical root for repositories, and the "-R" option to restrict connections to read-only access.  ("Read-only" is a logical term here; svnserve still needs write access to the database in this mode, but will not allow commits or revprop changes.)

1.3.2.1 Invoking the server:
$  svnserve -d -r ~/SVN/depot/projects
$ ps -ef | grep svn
root     32223     1  0 13:15 ?        00:00:00 svnserve -d -r /root/sarala/SVN/depot/projects

1.4 Create a repository
$  svnadmin create ~/sarala/SVN/depot/projects/repo1
$ cd ~/sarala/SVN/depot/projects/repo1
$ ls -lrt
-rw-r--r-- 1 root root  229 2011-02-16 13:39 README.txt
drwxr-xr-x 2 root root 4096 2011-02-16 13:39 locks
drwxr-xr-x 2 root root 4096 2011-02-16 13:39 hooks
-r--r--r-- 1 root root    2 2011-02-16 13:39 format
drwxr-sr-x 6 root root 4096 2011-02-16 13:39 db
drwxr-xr-x 2 root root 4096 2011-02-16 13:39 conf

1.5 Add / Import  files to repository
$ svn import ~/sarala/depot_files/project1 --username root --password svn123 svn://localhost/svn-repo

Adding         /root/sarala/depot_files/project1/a.c
Adding         /root/sarala/depot_files/project1/b.c
Committed revision 1.

$  svn import ~/sarala/depot_files/project2 --username root --password svn123 svn://localhost/svn-repo
Adding         /root/sarala/depot_files/project2/b.txt
Adding         /root/sarala/depot_files/project2/a.txt
Committed revision 2.

1.5.1 To list all the files in the repository
$ svn list svn://localhost/svn-repo
a.c
a.txt
b.c
b.txt

(OR)

$ svn ls  svn://localhost/svn-repo
a.c
a.txt
b.c
b.txt

For the moment, look at the command we have typed. We have used the standard ls command but we have used it as a svn command. This is an important aspect of svn: it allows you to manipulate files and directory (i.e. create, delete, move) with commands similar to the standard ones. So you really have the feeling you are just working with files but this is just the way svn presents them to you. Internally those files are managed with a database that is stored in the files you saw when listing the /home/user/svn/ directory. This virtual directory structure can be anywhere : on the local filesystem, on a remote machine, or even on a web server. For that reason, instead of talking of "filepath" for these virtual directories, svn uses the terminology URL. The URL must be prefixed to indicate how the repository should be accessed. That's why we have the file:// prefix. We will see other examples later. For the moment let's play with the virtual directory structure.
Some other examples are:

$ svn mkdir  svn://localhost/svn-repo/dir1  -m “Creating a directory inside the repository”
$ svn rm  svn://localhost/svn-repo/dir1  -m “Deleting a directory inside the repository”

1.5.2 Check the log of a file in the repository
$ svn log  svn://localhost/svn-repo/a.c

------------------------------------------------------------------------
r1 | root | 2011-02-17 12:11:51 +0530 (Thu, 17 Feb 2011) | 3 lines
Hii
--------------------------------------------------------------------------------


1.6 Importing a project with bunch of files in a specific directory structure
Suppose you have a directory structure with a bunch of files and you need to add them to the repository retaining their relative paths and can be done using the below command.
$ svn import ~/sarala/depot_files/ --username root --password svn123 svn://localhost/svn-repo/dir1       –m “Commiting code with directory structure into the repository” 
Adding         /root/sarala/depot_files/project1
Adding         /root/sarala/depot_files/project1/a.c
Adding         /root/sarala/depot_files/project1/b.c
Adding         /root/sarala/depot_files/project2
Adding         /root/sarala/depot_files/project2/b.txt
Adding         /root/sarala/depot_files/project2/a.txt
Committed revision 4.

The -m flag is used to give a log message for the action. Log messages are enforced by svn. If you do not want to use the -m flag on the command line, setup the SVN_EDITOR environment variable, for example to vi, and svn will prompt you with that editor anytime it needs a log message.

1.7 Checking out a project
$ mkdir /path/directory_to_checkout_the_code
$ cd /path/directory_to_checkout_the_code
$ Svn checkout svn://localhost/svn-repo
A    svn-repo/b.txt
A    svn-repo/dir1
A    svn-repo/dir1/project1
A    svn-repo/dir1/project1/a.c
A    svn-repo/dir1/project1/b.c
A    svn-repo/dir1/project2
A    svn-repo/dir1/project2/b.txt
A    svn-repo/dir1/project2/a.txt
A    svn-repo/a.c
A    svn-repo/b.c
A    svn-repo/a.txt
Checked out revision 4.

After the above command you will find a local copy of the repository under the directory /path/directory_to_checkout_the_code/svn-repo. This can also be verified by the presence of a “.svn” directory.

$ cd /path/directory_to_checkout_the_code/svn-repo
$ ls -lrt
total 20
drwxr-xr-x 5 root root 4096 2011-02-17 13:09 dir1
-rw-r--r-- 1 root root   60 2011-02-17 13:09 b.txt
-rw-r--r-- 1 root root  247 2011-02-17 13:09 b.c
-rw-r--r-- 1 root root   43 2011-02-17 13:09 a.txt
-rw-r--r-- 1 root root   82 2011-02-17 13:09 a.c

This can also be checked by the command “svn info”.
$ cd /path/directory_to_checkout_the_code/svn-repo
$ svn info
Path: .
URL: svn://localhost/svn-repo
Repository Root: svn://localhost
Repository UUID: d949aa33-3bf6-4f25-98b7-906b7cb10941
Revision: 4
Node Kind: directory
Schedule: normal
Last Changed Author: root
Last Changed Rev: 4
Last Changed Date: 2011-02-17 12:53:48 +0530 (Thu, 17 Feb 2011)

1.8 Editing and adding files:
Now that our project is safely under version controlled system, we can start making it evolve. First lets add another file new.c and then change a.txt file. After that we can check the status of our project as below:

$ cd /path/directory_to_checkout_the_code/svn-repo
$ \vi new.cc  (Create a new.c file using any editor of your choice and save it)
$ \vi a.txt  (Modify the a.txt file i.e add, delete or modify the contents of the file a.txt)
$ svn status
                ?       new.c
M       a.txt

The output of “svn status” command is very readable, it states there is one unknown file (?) new.c and one modified file (M).

Lets add the above two files to the repository:
$ svn add new.c

$ svn status
                A       new.c
M       a.txt
Now the status of new.c is being changes to “A” i.e added to the repository.

1.9 Committing the changes into the repository:
$ svn commit -m "Commiting the changes to the repository"
Sending        a.txt
Adding         new.c
Transmitting file data ..
Committed revision 5.


2. Versioning in svn:
When you committed your changes, svn indicated that it was version 5. Where that number comes from? Indeed, it is the very first commit so you would expect the revision to be 2, or 1.1 or something of that taste. Well, svn has a very different way of numbering files than CVS and it is one of its most pleasant feature. Everytime you change something (create a directory, remove a directory, commit modified or added files), svn attributes a new version number to all files. Everything happens as if the whole repository was copied everytime you do an svn command and svn enforces thinking that way. Of course, this is not what happens and svn saves only the relative changes in order to minimize the size of the database.
$ cd /tmp
$ svn checkout -r 5  svn://localhost/svn-repo
A    svn-repo/b.txt
A    svn-repo/dir1
A    svn-repo/dir1/project1
A    svn-repo/dir1/project1/a.c
A    svn-repo/dir1/project1/b.c
A    svn-repo/dir1/project2
A    svn-repo/dir1/project2/b.txt
A    svn-repo/dir1/project2/a.txt
A    svn-repo/a.c
A    svn-repo/b.c
A    svn-repo/new.c
A    svn-repo/a.txt
Checked out revision 5.

The meaning of “-r 5” should be self-explanatory. Look at the output. As you can see, this retrieved all files of your project. In other words, the version number is just a shortcut to the date at which the project is stamped.
Let's now get a copy of the previous version :
$ cd /tmp
$ svn checkout -r 4  svn://localhost/svn-repo
D    svn-repo/new.c
U    svn-repo/a.txt
Checked out revision 4.

Have a closer look at the output. It shows how clever svn is. We asked for version 4 but because of our previous command, the version 5 is already in /tmp. No problem, svn does all the necessary things and indicate them: the a.txt is updated and the new.c file is deleted. 

$ cd /path/directory_to_checkout_the_code/svn-repo
$ svn info a.c

                svn info a.c
Path: a.c
Name: a.c
URL: svn://localhost/svn-repo/a.c
Repository Root: svn://localhost
Repository UUID: d949aa33-3bf6-4f25-98b7-906b7cb10941
Revision: 4
Node Kind: file
Schedule: normal
Last Changed Author: root
Last Changed Rev: 1
Last Changed Date: 2011-02-17 12:11:51 +0530 (Thu, 17 Feb 2011)
Text Last Updated: 2011-02-17 13:09:23 +0530 (Thu, 17 Feb 2011)
Checksum: 2bb675411b289a4937db4c60e0f96126

3. References:
Subversion Web site:  http://subversion.apache.org