final oss lab manual

50
R.V.S. EDUCATIONAL TRUST’S GROUP OF INSTITUTIONS RVS SCHOOL OF ENGINEERING & TECHNOLOGY RVS Nagar, Dindigul- 624005 Phone. No.: 04551 - 227229,30,31&37 Fax No.: 04551 - 227229,30,31&37 website : http://rvsetgidgl.ac.in e-mail: [email protected] DEPARTMENT OF COMPUTER AND ENGINEERING NAME : S.Karthik YEAR : IV BRANCH : ECE SEM : VII SUBJECT CODE : 10144ECE33 SUBJECT NAME : High Speed Networks LAB MANUAL 1

Upload: karthik-singh

Post on 31-Dec-2015

24 views

Category:

Documents


1 download

DESCRIPTION

Software Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and PracticesSoftware Testing Principles and Practices

TRANSCRIPT

Page 1: Final Oss Lab Manual

R.V.S. EDUCATIONAL TRUST’S GROUP OF INSTITUTIONSRVS SCHOOL OF ENGINEERING & TECHNOLOGY

RVS Nagar, Dindigul- 624005Phone. No.: 04551 - 227229,30,31&37 Fax No.: 04551 - 227229,30,31&37

website : http://rvsetgidgl.ac.in e-mail: [email protected]

DEPARTMENT OF COMPUTER AND ENGINEERING

NAME : S.Karthik YEAR : IV

BRANCH : ECE SEM : VII

SUBJECT CODE : 10144ECE33 SUBJECT NAME : High Speed Networks

LAB MANUAL

1

Page 2: Final Oss Lab Manual

EX.NO:1 LINUX INSTALLATIONDATE: AIM :

To install linux operating system.Steps Involved:

Steps involved in Ubuntu installation

Step 1: The first thing you should do is head to  http://www.ubuntu.com/download/ ubuntu/download  and download Ubuntu 11.10 LiveCD. Just click the big orange Start download box.

Step 2: Using your disc burning software, burn the .iso you downloaded to a CD. 

Step 3: Before you go any further, ensure all important data is backed up in case of data loss on your drives. This guide assumes you have media backups of your Windows partitioned hard drive and you are safe to proceed.Step 4: Ensure you have a network cable connected, restart your computer, and boot from the CD drive.

Step 5: The LiveCD will load up, and you'll be presented by the following box:

For the purposes of this guide, we will assume you've already tried Ubuntu and want to proceed with an installation, so click "Install Ubuntu."

Step 6: You'll be greeted by the "Preparing to install Ubuntu" screen, exactly as below:

I recommend you select "Install third-party software" as I have done in the screenshot above. I prefer to do system updates once up and running, but if you have the extra time you can also select "download updates while installing" as well. Then click continue.

2

Page 3: Final Oss Lab Manual

Step 7: The next screen you will see is "installation type," what you see will be dependent on whether you have an existing Windows installation or not. 

I'm going to split this into three different sub-steps, to make it as simple as possible.

Step 7-A:For those installing in a virtual machine or to hard disks without an OS you will see the following screen:

You have two choices:

1. Erase the entire disk and use all of it for installation -- Ubuntu will automatically partition your disk and proceed with installation.2. Select "something else" and manually create your partitions (which is covered in detail in step 7-C).

If you are choosing the first option, select the radio button and then click continue, proceeding to step 8.

Step 7-B:Those of you that have current Windows installations or are going to dual-boot with another existing OS will be presented with a screen similar to below:

You have three options available:

1. You can choose the first option and install Ubuntu alongside your existing OS. 2. You can opt to replace your Windows installation with Ubuntu, allowing the installer to format your current partitions and automatically create new ones for Linux.3. You can choose "something else" and create your own partition scheme and sizing (covered in detail in step 7-C).

Once you have selected which route you wish to proceed with click continue and proceed to step 8.

Step 7-C:Having selected the "something else" option you will be presented with the following window:

Linux recognizes and assigns IDs to drive in a different manner to Windows. In the above image, you can clearly see my hard disk in the list. It is identified by "/dev/sda." Linux recognizes drives in the following way: • Sda = 1st drive• Sdb = 2nd drive• Sdc = 3rd drive and so on 

Partitions are also shown after the drive letters. So if I had 2 partitions on my first disk, they would be identified as:• Sda1 – 1st drive, 1st partition• Sda2 – 1st drive, 2nd partition

You will not see the common Windows C: label in the disk menu in the above list. You do, however, have key things to help you recognize your Windows C: drive. Both of these can be used to identify which is your Windows disk.• The size of the disk is shown

3

Page 4: Final Oss Lab Manual

• The name of the drive is shown

This is your current partition layout for your hard disks. If you have more than one disk, they will show up as /dev/sda, /dev/sdb etc.

Firstly, identify your Windows installation. In my case, it's sda1 (which is my first hard disk, first partition). What you see depends on how you created the extra space. I just resized the Windows partition from within Windows, and left the free space ready to install Linux. I recommend using Windows or a free utility from within Windows to resize your partition as most beginners will understand it more.

Therefore, we now need create a minimum of two partitions:

Click "Add" and the following box will appear:

You will notice I have already filled out the example above to create a 10GB root partition.

You can have a maximum of 4 primary partitions, or 3 primary partitions and 1 logical (which allows for another 64 partitions)The size above is 10.00GB. e.g 1,000 = 1GB 10,000 = 10GB (Remember to leave enough free remaining space to create your SWAP partition!)Location for new partition: e.g. do you want it at the start or end of the free space. Select beginning.Use as: Ext4 is the recommended file system for Ubuntu, much the same as NTFS is Windows. SWAP is for SWAP space.Mount point: This is where you want the partition to mount. E.g. we need a root partition, which in Linux is denoted by a "/".

Click OK once you have finished setting the partition information and you will return to your partition screen, now showing the root partition you just created. Using the same methods as before, create a SWAP partition. 

I recommend you set the size of your SWAP partition to at least the size of your available RAM. If you have plenty of hard disk capacity I would suggest you use double the size. So if you have 2GB of RAM, set it to either 2GB or 4GB. For best performance it is recommended you have your SWAP partition at the beginning or end of your drive.

Once you have done that, you should be looking at something like below.

So to re-cap the above, (in my example) we have the following:

• /dev/sda1 is your Windows partition.

• /dev/sda2 is your new root partition (Windows equiv. of C .• /dev/sda3 is your SWAP space.

Once you are happy with the changes you have made, click install now and proceed to the next step.

Step 8:As the installation starts to copy the required files to the hard disk, you will be presented with a screen to select your locale. It should automatically find where you are, as it has for me already:

4

Page 5: Final Oss Lab Manual

Just double check it is correct, and then select continue.Step 9:The next screen to appear will be keyboard layout:Ensure the correct option is selected, above you will see the correct (and default UK) selection has been automatically made for me.Step 10:You will now be greeted by the "who are you" screen, ready for you to fill out with your user details:The omputers name and username will automatically populate when you type your full name. You can however edit them as you please. Fill in the details and then click continue.You can opt to have Ubuntu automatically log in for you -- even with a password set -- or you can choose the traditional option requiring a password to log in. You really don't need to choose the encrypt option unless you're installing on a laptop and are dealing with highly secure information.Step 11:The installation information screens will now appear as Ubuntu continues the installation:

Step 12:Once installation has finished, you will be presented with the following box:

Select "restart now" and when requested, remove your installation CD, then press enter to reboot.======++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++======

EX.NO:2 MySQL INSTALLATIONDATE:AIM :

To Perform Mysql Intallation On Linux Operating System INSTALLATION PROCESS:

[ r oot@ s erver root]# cd /root[ r oot@ s erver root]# mkdir /root/files /data /data/mysql[ r oot@ s erver root]# cd files[ r oot@ s erver root]# wget http://www.d9x.net/download s /unix/my s ql- 4.0.12.tar.gz[ r oot@ s erver root]# tar xzvf mysql-4.0.12.tar.gz[ r oot@ s erver root]# cd mysql-4.0.12if your using FreeBSD use "adduser" instead of "useradd". [ r oot@ s erver root]# groupadd mysql[ r oot@ s erver root]# useradd -g mysql mysql[ r oot@ s erver root]# ./configure --prefix=/usr/local/mysql--datadir=/data/mysql

DataDir is where your mysql databases will be stored including the database which contains all mysql user accounts, you can easily backup all databases/users by saving the contents of this folder. /data/mysqlif you get a "mod_auth_dbm" Error

Copy the ndbm.h file from /usr/include to the /usr/include/db1 directory (or install b1-devel)if you get a "no acceptable C compiler found in $PATH" Error

Install a c compiler, example:gccif you get "libmysql.c:1349: warning: passing arg 5 of `gethostbyname_r' from incompatible pointer type" Error

you need to install a c++ compiler, install: libstdc++-devel, gcc-c++ (same version as gcc)[ r oot@ s erver root]# make[ r oot@ s erver root]# make install[ r oot@ s erver root]# ./scripts/mysql_install_db[ r oot@ s erver root]# ln -s /usr/local/mysql/share/mysql/mysql.server/sbin/mysqld

5

Page 6: Final Oss Lab Manual

[ r oot@ s erver root]# chown -R mysql:mysql /data/mysql[ r oot@ s erver root]# chown -R mysql:mysql /usr/local/mysqlS T AR T , S T OP & R E ST ART S Q L: [ r oot@ s erver root]# mysqld start [ r oot@ s erver root]# mysqld stop[r oot@server root]# mysqld restartU SI NG MYS Q L:

EXPORT DATABASE[ r oot@ s erver root]#/usr/local/mysql/bin/mysqldump-uroot-pdatabase_name> database_name.sql IMPORT DATABASE[ r oot@ s erver root]#/usr/local/mysql/bin/mysql -u root -p database_name <database_name.sql

SET ROOT PASSWORD[ r oot@ s erver root]# /usr/local/mysql/bin/mysqladmin -u root -p password NEW_PASSNOTE: When it prompts you to enter the password, just hit Enter if you don't see an error, the password was successfully changed.U N I N ST A L LI NG MYS Q L:

[ r oot@ s erver root]#rm-rf/usr/local/mysql [ r oot@ s erver root]# rm -rf /data/mysql [r oot@server root]# rm -rf /sbin/mysqldRESULT :

Thus the MYSQL was successfully installed on linux operating system.EX.NO:3 APACHE INSTALLATIONDATE:AIM :

To perform Apache installation. I N T RODU C T ION:

The Apache Web server is arguably the most popular Web server in use on the Internet today. Here are some of the reasons why Apache is so popular; you don't have to be running Windows to run Apache. It was developed on various Unix/Linux/BSD platforms, and then recently ported to Win32. Internet Information Server, a Web server made by Microsoft for the Windows NT platform, is made for use in the "Windows-only" world. While IIS has many features, its lack of portability limits it’s market share.

If you're hosting a pretty plain Web site with mostly static content, Apache is a fireball. If you throw tons of CGI scripts at it, while making database calls at the same time, you're going to slow it down. Though much of the slowdown will come from your scripts themselves, and not from Apache. Apache evolved out of the NCSA https project to its current status as one of the fastest, most efficient, and most functional web servers in existence today.

Apache has been shown to be substantially faster, more stable, and more feature-full than many other web servers. Although certain commercial servers have claimed to surpass Apache's speed. The developers of Apache feel that it is better to have a mostly-fast free server than an extremely fast server that costs thousands of dollars.

Apache is run on sites that get millions of hits per day, and they have experienced no performance difficulties. Apache is run on over 10 million Internet servers (as of May 2002). It has been tested thoroughly by both developers and users. The Apache Group maintains rigorous standards before releasing new versions of their server, and their server runs without problems on over one half of all WWW servers available on the Internet. When bugs do show up, they release patches and new versions as soon as they are available.INSTALLAT ION OPTIONS:

I’ll cover three methods of installing Apache under Linux. The three methods are:

6

Page 7: Final Oss Lab Manual

Binary installation Using an RPM (Red Hat Package Manager) – recommended for people running

Red Hat Linux Building from source

APACHE INSTALLATION GUIDE:We recommend using the RPM installation method. This is the easiest way to install Apache

for people that are new to Linux.DOWNLOAD THE SOFTWARE:

You can download Apache from the Apache Software Foundation web site located at h tt p : //www.apache.or g, in source and binary forms. While your downloading Apache, you may want to browse over the documentation.

WHAT YOU NEED:To install Apache, you will need the following things:1. A computer running Linux2. Root access on this computer3. For binary and source installations, the tar and gunzip Unix utilities

BINARY INSTALLATION:A binary is pre-configured, which means someone else has gone to the trouble of configuring

and building the software for you. There are, however, a few things you should keep in mind: Binaries are compiled for a particular operating system. In other words, you must use a

binary built specifically for FreeBSD on your FreeBSD machine and a Linux binary on your Linux machine. You need to be sure to grab the correct binary; if you don't see a binary for your particular operating system, you must choose a different method of installation.

Apache binaries are usually a version or two behind the current source distribution. his means you don't reap the benefits of the latest bug fixes and feature nhancements.

Because binaries are pre-configured, you don't have much opportunity to alter the way the software works. If you're a newcomer, you may not care about this loss of flexibility. Fortunately most Apache binaries include a full source distribution, providing you with the best of both worlds -- play now, learn later.

Now let's install a binary. Point your browser at h tt p : //www.apache.org / di s t /h t t pd/ b inarie s / Download the binary for your operating system (in our case, Linux). You'll most likely be

presented with a directory containing multiple versions of Apache in various compressed forms. For the purposes of this guide, I'll assume you've downloaded the gzip'd form of the latest 2.0.x Apache binary (currently that's httpd-2.0.35-i686-pc-linux-rh72.tar.gz). If there is a README associated with the file you're downloading, you may want to review it for any interesting installation tidbits or possible bugs.

If you can't find a binary for your operating system, choose either the RPM Installation (if you are running Red Hat Linux) or Build from Source method. Now let's uncompress the archive using the handy combination ofgunzip and tar. You should replace the "httpd-2.0.35-i686-pc-linux- rh72.tar.gz" text below with the name of the gzip'd file you downloaded. gunzip < httpd-2.0.35-i686-pc-linux-rh72.tar.gz | tar xvf –Some of you may be lucky enough to have a version of tar that is capable of taking care of both tasks.

tar xvzf httpd-2.0.35-i686-pc-linux-rh72.tar.gzEither way, you should end up with an httpd-2.0.x directory, with x being the particular subversion of Apache you downloaded. Move into the newly created directory.

cd httpd-2.0.xAs of Apache 1.3.11, binary distributions contain an install script called install.bindist.sh. If your

binary does not seem to contain such an install script, take a look at the README.bindist and/or INSTALL.bindist documents for further information; if these documents don't outline a simple installation method, you'll probably want to use one of the other methods I cover in this guide.

If you've not already done so, you'll need to become root. You can become root by typing su, then the root password. Then go ahead and run the install script

7

Page 8: Final Oss Lab Manual

./install.bindist.shThis command should install the various bits of the Apache distribution into the appropriate

locations; the default is usually to install everything under /usr/local/apache (confirm this by consulting your README.bindist and/or INSTALL.bindist documents). That's all there is to it on installing binaries.RPM INSTALLATION:

Those of you running Red Hat Linux may want to take advantage of Red Hat's RPM ("RedHat Package Manager") system. Almost identical to a binary, an RPM is further customized to play nicely with other RPMs and provide a consistent interface to installing, updating, and removing binaries.For Linux newcomers or when installing a small standard component, RPMs are simple and reliable. Bear in mind that an Apache RPM may already be installed on your system depending on how Linux was originally installed on your computer. To find out, at the shell prompt, type:

rpm -qa | grep apacheIf you see something like apache-1.3.9xxx, an Apache RPM has already been installed.

You can also type that command typing httpd instead of apache to see if it’s installed. If you don't have an Apache RPM, you must obtain one. Red Hat 7.3 ships apache-1.3.23- 11.src.rpm in the RedHat/RPMS directory on the installation CD. Or, point your browser at ftp://ftp.redhat.com/pub/redhat/redhat-7.3-en/os/i386/RedHat/RPMS and ownload it.If you've not already done so, you'll need to become root. Navigate to the same directory as the .rpm file you obtained, and then type the following command, substituting the name of the .rpm you're using for example: apache-1.3.23-11.src.rpm.

rpm -ivh apache-1.3.23-11.src.rpmRPM should grind away, displaying its progress with a primitive ####### progress bar. Barring any errors, you're done.

BUILD FORM SOURCE:Building Apache from source may seem like a daunting task to newcomers, but the Apache

developers have done a wonderful job of making the task about as simple as could be. Just three more commands than a binary installation and you skip the arduous task of figuring out which binary is the right one for your particular operating system. Point your browser at http : //www.apache.org/di s t/httpd/ and download the gzip'd form of the current version of Apache (2.0.36 at the time of this writing). Now let's uncompress that archive using gunzip and tar. You should replace the httpd- 2.0.36.tar.gz below with the name of the gzip'd file you downloaded.

gunzip < httpd-2.0.36.tar.gz | tar xvf –`You should end up with an httpd-2.0.x directory, x being the particular sub- version of Apache

you downloaded. Move into the newly created directory.cd httpd-2.0.xNow we'll use the the configure and make commands to configure, make, and install Apache. If

you've not already done so, now would be the time to become root../configure

Your screen should look something like:# ./configure

checking for chosen layout... Apache checking for working mkdir -p... yeschecking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu Configuring Apache Portable Runtime library ...config.status: executing default commandsUnless errors were reported (not warnings), your Apache installation is now configured and we

can move on. This is where things get a bit ugly. Make'ing Apache produces screenfulls of output.

8

Page 9: Final Oss Lab Manual

MakeYour screen should look something like:

# makeMaking all in srclibmake[1]: Entering directory `/home/ryan/dl/apache_guide/httpd-2.0.36/srclib' Making all in aprmake[2]: Entering directory `/home/ryan/dl/apache_guide/httpd-2.0.36/srclib/apr'...make[1]: Leaving directory `/home/ryan/dl/apache_guide/httpd-2.0.36'#

Finally, you're ready to install your Apache build.# make install

Now Apache is installed.STARTING APACHE:

Let's take your new Apache installation out for a spin. If you installed Apache using a binary or from scratch, as root, type:

/usr/local/apache/bin/apachectl startIf you used an RPM, as root, type:

/sbin/service httpd startPoint your browser at your brand new Web server, http:/ / localho s t/. If everything

worked you should see the default home page.C U ST O MI ZE:

Apache uses some rather easy to understand text files for configuration. On a Red Hat system,you'll find them in /etc/httpd/conf. Quite a few Linuxdistributions place them in this same place, but if you can't find such a directory, do a search for "httpd.conf".

Once you find these, you've found the main config files. If you're new to Linux, and need help finding this file, here's how you can find it.

1.Login as root2.Type: cd /3.Type: find -name httpd.confNow you should see where the file is located. When you move into the directory

containing httpd.conf, you should see these three files:·httpd.conf – This has the settings for the overall configuration for the server.·access.conf – This file contains all the security settings for Apache.·srm.conf – This file contains the MIME definitions and default document names for files RESTARTING APACHE:

Whevever you make changes to the server configuration files, such as httpd.conf, they won't take effect until the server is restarted. In Linux, Apache can be restarted depending on how you installed it. If you installed Apache using a binary or from scratch, as root, type:

/usr/local/apache/bin/apachectl startIf you used an RPM, as root, type:

/sbin/service httpd startAfter being restarted the changes will have taken effect.

RESULT : Thus the apache server was successfully installed on linux operating system.EX.NO:4(a) PALINDROME OR NOTDATE:AIM:

To write a PHP program for palindrome.ALGORITHEM:

9

Page 10: Final Oss Lab Manual

STEP 1: Start the program. STEP 2: Create the function for palindrome as palin. STEP 3: Check the condition for the given String. STEP 4: If the condition is true means, display as the given String is a “Palindrome”. STEP 5: Otherwise display as, the given string is “not a Palindrome”. STEP 6: Stop the program. PROGRAM:<html><body><?phpFunction palin($string){$string_reversed=strrev($string);If($string==$string_reversed){echo “$string is a palindrome”;}Else{echo “$string is not a palindrome”;}}Palin(“madam”);?> </body> </html>OUTPUT:Madam is a palindrome.RESULT: Thus the PHP program for palindrome has been executed and output is verified successfully.

EX.NO:4(b) MULTIPLICATION TABLEDATE:AIM:

To write a PHP program for the multiplication table.ALGORITHM: STEP 1: Start the program. STEP 2: Create the title as MULTIPLIATION TABLE by using the necessary tags. STEP 3: Create the table border. STEP 4: To create the particular number of rows and columns. STEP 5: By using <td> the data elements are added in the cell. STEP 6: Then perform the multiplication for the data of rows and columns. STEP 7: Stop the program.PROGRAM:

<html><head><title>MULTIPLICATION TABLE</title></head><body><?phpecho “MULTIPLICATION TABLE”echo “<table border=\”1\”>”;for($row=1;$row<=5;$row++){Echo “<tr>”;

10

Page 11: Final Oss Lab Manual

For($col=1;$col<=5;$col++){$x=$x=$col*$row;Echo “<td>$x</td>”;}Echo “</tr>”;}Echo “</table>”;?></body></html>

OUTPUT:

RESULT: Thus the PHP program for the multiplication table has been executed and output is verified successfully.EX.NO:4(c) ADD USER INPUT TO ARRAYDATE:AIM:

To write a PHP program to add user input to an array.ALGORITHM: STEP 1: Start the program. STEP 2: Create the title as “User Input Added to Array” by using the necessary tags. STEP 3: Create the form . STEP 4: To create an array with string elements. STEP 5: Add the elements to an array. STEP 6: Stop the program.PROGRAM:<head><title>User Input Added to Array</title></head><body><h2>How Are You Traveling?</h2><?php//If form not submitted, display form. if (!isset($_POST['submit'])){$travel=array("Automobile", "Jet", "Ferry", "Subway"); ?><p>Travel takes many forms, whether across town, across the country, or around the world. Here is a list of some common modes of transportation:</p><ul><?phpforeach ($travel as $t){echo "<li>$t</li>\n";}?></ul><form method="post" action="yourfile.php">

11

1 2 3 4 5

2 4 6 8 10

3 6 9 12 15

4 8 12 16 20

5 10 15 20 25

Page 12: Final Oss Lab Manual

<p>Please add your favorite, local, or even imaginary modes of travel to the list, separated by commas:</p><input type="text" name="added" size="80" /><p /><?php//Send current travel array as hidden form data. foreach ($travel as $t){echo "<input type=\"hidden\" name=\"travel[]\" value=\"$t\" />\n"; }?><input type="submit" name="submit" value="Go" /></form><?php//If form submitted, process input.}else{//Retrieve established travel array.$travel=($_POST['travel']);//Convert user input string into an array.$added=explode(',',$_POST['added']);//Add to the established array. array_splice($travel, count($travel), 0, $added);//This could also be written $travel=array_merge($travel, $added);//Return the new list to the user.echo "<p>Here is the list with your additions:</p>\n<ul>\n";foreach($travel as $t){//The trim functions deletes extra spaces the user may have entered. echo "<li>".trim($t)."</li>\n";}echo"</ul>"; ?><p>Add more?</p><form method="post" action="yourfile.php"><input type="text" name="added" size="80" /><p /><?php//Send current travel array as hidden form data. foreach ($travel as $t){echo "<input type=\"hidden\" name=\"travel[]\" value=\"$t\" />\n";}?><input type="submit" name="submit" value="Go" /></form><?php}?></body></html>RESULT: Thus the PHP program for the addition of elements to the array has been executed and output is verified successfully.

EX.NO:5(a) FINDING GREATEST VALUEDATE:AIM: To write a simple program in python for finding the greatest value among three numbers.ALGORITHM: STEP 1: Start the program.

12

Page 13: Final Oss Lab Manual

STEP 2: To get the three input values from the user. STEP 3: Check the ‘if’ condition and if it is true, print “Number 1 is greater”. STEP 4: Otherwise check ‘elif’ condition and if it is true, print “Number 2 is greater”. STEP 5: Both the condition is failed means, print “Number 3 is greater”. STEP 6: Stop the program.PROGRAM#! /usr/bin/python# program to find greatest among three numbersno1 = raw_input("Enter the First Number ")no2 = raw_input("Enter the Second Number ")no3 = raw_input("Enter the Third Number ")if no1 > no2 and no1 > no3:

print "Number 1 is greater "elif no2 > no3:

print " Number 2 is greater "else:

print " NUmber 3 is greater "OUTPUT:root@localhost siva]# ./ifstat.pyEnter the First Number 30Enter the Second Number 20Enter the Third Number 10Number 1 is greater [root@localhost siva]# ./ifstat.pyEnter the First Number 10Enter the Second Number 30Enter the Third Number 20 Number 2 is greater [root@localhost siva]# ./ifstat.pyEnter the First Number 10Enter the Second Number 20Enter the Third Number 30 Number 3 is greater [root@localhost siva]# RESULT: Thus the python program for finding the greatest value among the three numbers has been executed successfully

EX.NO:5(b) FINDING FIBONACCI SERIES AND FACTORIALDATE: VALUESAIM: To write a python program for generating Fibonacci series and find factorial of a number using looping statements.ALGORITHM: STEP 1: Start the program. STEP 2: To calculate factorial value of a number using fact=fact*i. STEP 3: Define the input as 0 and 1 to generate the Fibonacci series upto 10 numbers. STEP 4: Print the result. STEP 5: Stop the program.PROGRAM:#! /usr/bin/python# program to demonstrate for loop and range

13

Page 14: Final Oss Lab Manual

# program to find the factorial of a number and generate Fibonacci seriesfact = 1for i in range(1,5):

fact = fact * iprint "Factorial of 5 is ", facta,b = 0, 1print " The first 10 fibonacci numbers are "for i in range(10):

c = a + bprint ca = bb = c

OUTPUT[root@localhost siva]# ./loop.pyFactorial of 5 is 24 The first 10 fibonacci numbers are 123581321345589[root@localhost siva]#

RESULT: Thus the python program for generating Fibonacci series and factorial of a number has been executed successfully.EX.NO:5(c) STRING OPERATIONSDATE: AIM: To write a python program to perform string operation.ALGORITHM:

STEP 1: Start the program.STEP 2: Get the input string from the user.STEP 3: By using str.upper () and str.lower () functions to display the given string in upper and lower cases respectively. STEP 4: By using str[:] to display the particular character from the string.STEP 5: By using count () and len () functions display the count value of the particular and length of the string.STEP 6: Stop the program

PROGRAM:#! /usr/bin/pythonstr = raw_input("Enter the String ")print "Upper Case of the Given String is " print str.upper()print "Lower Case of the Given String is "print str.lower()print "The First Five Characters of the String is " + str[:5]

14

Page 15: Final Oss Lab Manual

print "The last Five character of the String is " + str[:-6]print "The characters after the sixth location " + str[6:]print "The characters between 3 and 8 is " + str[3:8]print "The Number of 'e' in the String is ", str.count('e')print "The Length of the String is " , len(str)

OUTPUT:[root@localhost siva]# chmod a+x stropr.py[root@localhost siva]# ./stropr.pyEnter the String Welcome to Python ProgrammingUpper Case of the Given String is WELCOME TO PYTHON PROGRAMMINGLower Case of the Given String is welcome to python programmingThe First Five Characters of the String is WelcoThe last Five character of the String is Welcome to Python ProgrThe characters after the sixth location e to Python ProgrammingThe characters between 3 and 8 is come The Number of 'e' in the String is 2The Length of the String is 29[root@localhost siva]# RESULT: Thus the python program for performing string operation has been executed successfully and output is verified.EX.NO:5(d) COPYING FILE BY USING EXCEPTION HANDLINGDATE: AIM: To write a program for copying content of one file to another file Using exception handling in python.ALGORITHM: STEP 1: Start the program. STEP 2: Create the exception block. STEP 3: Create the source file as ‘r’ and destination file as ‘w’. STEP 4: Get the input in source file and output in destination file. STEP 5: By using the write (line) function the source file is copied to the destination file ‘w’. STEP 6: Then print the result as “File copied successfully”. STEP 7: Stop the program.PROGRAM:

# Copying content of one file to anothersfilename = raw_input("Source Filename ")dfilename = raw_input("Destination Filename ")try:

input = open(sfilename, 'r')except:

print "Unable to open file "output = open(dfilename,"w")for line in input.readlines():

output.write(line)print "file copied successfully"input.close()output.close()

OUTPUT:[root@localhost siva]# python filex.py

15

Page 16: Final Oss Lab Manual

Source Filename stropr.pyDestination Filename str.pyfile copied successfully[root@localhost siva]# cat str.py#! /usr/bin/pythonstr = raw_input("Enter the String ")print "Upper Case of the Given String is " print str.upper()print "Lower Case of the Given String is "print str.lower()print "The First Five Characters of the String is " + str[:5]print "The last Five character of the String is " + str[:-6]print "The characters after the sixth location " + str[6:]print "The characters between 3 and 8 is " + str[3:8]print "The Number of 'e' in the String is ", str.count('e')print "The Length of the String is " , len(str)

RESULT: Thus the python program for copying the content of source file to destination file using exception handling has been executed successfully and output is verified.

EX.NO:5(e) FUNCTIONS IN LISTDATE:

AIM: To write a program for performing functions in lists using python.ALGORITHM:STEP 1: Start the program.STEP 2: Create the list with the values of various data types.STEP 3: Then perform the list operations such as print the whole list and also print the element with starting and ending values,list concatenatio and modification on the list, appending operation on the list and deleting element on the list. STEP 4: Print all the result. STEP 5: Stop the program.PROGRAM:

#Python Lists#!/usr/bin/pythonprint("\t \t \t Python Lists");list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]tinylist = [123, 'john']print("Prints complete list:",list);print("Prints first element of the list : ",list[0]);print("Prints elements starting from 2nd to 4th:",list[1:3]); print("Prints elements starting from 3rd element:",list[2:]); print("Prints list two times:",tinylist * 2);print("Prints concatenated lists: ", list + tinylist );#modify the 4th elements in the listprint("Before modifying the 4th element in list :",list[4]);list[4]='efgh';print("4th element in list :",list[4]);print(" complete list:",list);#Appending new elements

16

Page 17: Final Oss Lab Manual

list.append('ijkl');print("After appending list:",list);#deleting an element in listdel list[2];print("List :",list);

OUTPUT:[root@localhost~]#python pg6.pyPython listPrints complete list: [‘abcd’, 786, 2.23,’john’, 70.20000000000003]Prints first element of the list: abcdPrints element starting from 2nd and 4th: [786, 2.23]Prints element starting from 3rd element:[2.23,’john’,70.2000000000003]Prints concatenated list: [ ‘abcd’, 786, 2.23,’john’, 70.20000000000003, 123,’john’]Before modifying the 4th element in list: 70.2Fourth element in the list: efghComplete list: [‘abcd’, 786, 2.23,’john’,’efgh’]After appending list: [‘abcd’, 786, 2.23,’john’,’efgh’,’ijkl’]List1: [‘abcd’, 786, ’john’,’efgh’,’ijkl’][root@localhost~]#

RESULT: Thus the python program for creating the list and performing functions in the list has been executed successfully and output is verified.

EX.NO:5(f) PRIME OR NOTDATE:

AIM: To write a python program for the given number is prime or not.

ALGORITHM: STEP 1: Start the program. STEP 2: By using the ‘for’ loop we may give the range of the number. STEP 3: In the ‘if’ condition we check the remainder value given by the modulo operation. STEP 4: If it is zero means then print the reason as ‘n’ equals ‘x*n/x’. STEP 5: Stop the program.

PROGRAM:#!/usr/bin/pythonfor n in range(2, 10):for x in range(2, n):if n % x == 0:print n, 'equals', x, '*', n/xbreakelse:print n, 'is a prime number'

OUTPUT:2 is a prime number

17

Page 18: Final Oss Lab Manual

3 is a prime number4 equals 2 * 25 is a prime number6 equals 2 * 37 is a prime number8 equals 2 * 49 equals 3 * 3

RESULT: Thus the python program for checking prime number has been executed successfully and output is verified.

EX.NO:6(a) FIND MAXIMUM VALUES USING FUNCTIONDATE:

AIM: To write a perl program for finding the maximum values using function.

ALGORITHM: STEP 1: Start the program. STEP 2: Create the function as submax(). STEP 3: Shift function is used to remove the first element in the array. STEP 4: Then compare each element in the array and find the maximum value with the help of

‘foreach’ statement. STEP 5: Print the maximum value. STEP 6: Stop the program. PROGRAM:

#!usr/bin/perl sub max(){$max=shift @_; foreach $v ( @_) # $v is the second values in the @_{$max=$v if $max<$v;}return $max;}$d=&max (10, 278, 1050, 76, 800, 246, 76, 345);print "The maximum value is $d\n";

OUTPUT:[ linuxpert@localho s t ~]$ perl functionparam.plThe maximum value is 1050

RESULT: Thus the perl program for finding the maximum value using function has been executed successfully and output is verified.

EX.NO:6(b) GREATEST AMONG THREE NUMBERSDATE:

AIM:

18

Page 19: Final Oss Lab Manual

To write a perl program to check the greatest number among three.

ALGORITHM: STEP 1: Start the program. STEP 2: Get the three numbers at runtime. STEP 3: Then by using ‘if’ and ‘elsif’ condition check the greatest number. STEP 4: Print the result. STEP 5: Stop the program.PROGRAM:

#Greatest among 3 number print "Enter A value : ";$a=<>;print "Enter b value : ";$b=<>;print "Enter c value : ";$c=<>;if(($a > $b)&&($a > $c)){print "A is greater";}elsif(($b > $c)&&($b > $a)){print "B is greater";}else{print "C is greater";}

OUTPUT:[root@localhost~]#perl pl2.plEnter A value :100Enter B value :50Enter C value :30A is greater[root@localhost~]#

RESULT: Thus the perl program for checking the greatest number among three has been executed successfully and the output is verified.

EX.NO:6(c) GET DETAILS IN RUNTIMEDATE: AIM: To write a perl program to get the user details in runtime.ALGORITHM:

STEP 1: Start the program.STEP 2: Get the student information at runtime using the chomp().STEP 3: Print the student informationSTEP 4: Stop the program.

19

Page 20: Final Oss Lab Manual

PROGRAM:#! usr/bin/perlprint "Enter the Student Information";print "\n enter name"; chomp($name = <>); print "\nenter dob"; chomp($dob=<>);print "\n enter registerno."; chomp($registern0.=<>); print "\n enter education"; chomp($Education=<>);print "\n Student Information";print "\n Name: $name";print "\n Date Of Birth :$dob";print "\n Register no.:$registern0.";print "\nQualification :$Education";

OUTPUT:[root@localhost~]#pg.plEnter the student informationEnter name: xxxEnter DOB: 19.10.1990Enter register no: 100405307014Enter education: BEStudent informationName: xxxDate of birth: 19.10.1990Register no: 100405307014Qualification: BERESULT: Thus the perl program for getting user details at runtime has been executed successfully and the output is verified.

EX.NO:6(d) DATA MANIPULATIONDATE: AIM:

To write a perl program for performing the manipulation on date.ALGORITHM: STEP 1: Start the program. STEP 2: By using the built_in functions such as abs(), int abs(), sqrt(), and also using the

string function such as lc(), uc(), substr() manipulate the string. STEP 3: Print the result. STEP 4: Stop the program.PROGRAM:# Data Manipulation in Perlprint " absolute value of -1.295476 is ", abs(-1.295476),"\n";print "Integer equivalent of the above is ", int abs(-1.295476),"\n";print " Square root of 16384 is", sqrt(16384),"\n";print " String case conversion ","\n";$string = "All that glitters are not gold","\n";print $string,"\n";print "Lower case equivalent : ", lc($string),"\n";

20

Page 21: Final Oss Lab Manual

print "Upper case equivalent : ", uc($string),"\n";print "Index of glitters is : " ;print index($string,'glitters'),"\n";print "First three characters of the string is : ", substr($string,3),"\n";print "Last 10 characters of the string is : ", substr($string, -7),"\n";

OUTPUT:$ perl dman.pl absolute value of -1.295476 is 1.295476Integer equivalent of the above is 1 Square root of 16384 is128 String case conversionAll that glitters are not goldLower case equivalent : all that glitters are not goldUpper case equivalent : ALL THAT GLITTERS ARE NOT GOLDIndex of glitters is : 9First three characters of the string is : AllLast 10 characters of the string is : not gold

RESULT: Thus the perl program for performing the data manipulation has been executed and the output is verified successfully.

EX.NO:6(e) PERL SCRIPT TO DETECT WEB BROWSERDATE: AIM: To write a perl program to detect the web browser.ALGORITHM: STEP 1: Start the program. STEP 2: Create a script in the perl. STEP 3: Create the variable user agent as $ua. STEP 4: To select and detect the web browser using ‘if’ condition. STEP 5: Depends upon the condition print result. STEP 6: Stop the program.PROGRAM:

#!/usr/bin/perl -wTuse CGI qw(:standard);use CGI::Carp qw(warningsToBrowser fatalsToBrowser);use strict;print header;print start_html("Browser Detect");my($ua) = $ENV{HTTP_USER_AGENT};print "User-agent: $ua<p>\n";if (index($ua, "MSIE") > -1) { print "Your browser is Internet Explorer.<p>\n";} elsif (index($ua, "Netscape") > -1) { print "Your browser is Netscape.<p>\n";}

21

Page 22: Final Oss Lab Manual

elsif (index($ua, "Safari") > -1) { print "Your browser is Safari.<p>\n"; } elsif (index($ua, "Opera") > -1) { print "Your browser is Opera.<p>\n";} elsif (index($ua, "Mozilla") > -1) { print "Your browser is probably Mozilla.<p>\n";} else { print "I give up, I can't tell what browser you're using!<p>\n";}print end_html;

OUTPUT:User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AskTbARS/5.8.0.12304) Your browser is Internet Explorer.

RESULT: Thus the perl program for detecting the WEB BROWSER has been executed successfully.

EX.NO:7(a) SIMPLE GUI PROGRAMMINGDATE: AIM: To write a QT program to display “Hello World”ALGORITHM: STEP 1: Start the program. STEP 2: Create a new directory for the program.

mkdir qthellocd qthello

STEP 3: create the file in the qthello directory.gedit qthello.cpp

STEP 4: Once the file has been saved, use the following commands to compile and execute the program..

> qmake-qt4 -project> qmake-qt4

> make> ./qthello

STEP 5: Stop the program.PROGRAM:

//qthello.cpp//Include file for Qt#include <QtGui>int main(int argc, char *argv[]){

QApplication app(argc, argv); QWidget

22

Page 23: Final Oss Lab Manual

window;//resize window to 320x240 window.resize(320, 240);

window.setWindowTitle(“Hello World!”);//Show the window

window.show();//Start the event loop return

app.exec();}

OUTPUT:

RESULT: Thus the simple QT program is has been executed successfully.

EX.NO:7(b) SIMPLE GUI PROGRAMMING – BUTTON CREATIONDATE: AIM: To write a QT program to create Window with buttonALGORITHM: STEP 1: Start the program. STEP 2: Create a new directory for the program.

mkdir qtbuttoncd qtbutton

STEP 3: create the file in the qtbutton directory.gedit qtbutton.cpp

STEP 4: Once the file has been saved, use the following commands to compile and execute the program..

> qmake-qt4 -project> qmake-qt4

> make> ./qtbutton

STEP 5: Stop the program.PROGRAM:

#include <QtGui>

23

Page 24: Final Oss Lab Manual

int main(int argc, char *argv[]){

QApplication app(argc, argv); QWidget window;

24

Page 25: Final Oss Lab Manual

window.resize(320, 240); window.setWindowTitle(“Window with a button”); window.show();//Create a button with the text “Press me”//as a child of the main windowQPushButton *button = new QPushButton("Press me", &window);//move the button into position button->move(100, 100);button->show();return app.exec();

}

OUTPUT:

RESULT: Thus the simple QT program is has been executed successfully.

EX.NO:7(C) SIMPLE GUI PROGRAMMING- LAYOUT CREATIONDATE: AIM: To write a QT program to create Window with buttonALGORITHM: STEP 1: Start the program. STEP 2: Create a new directory for the program.

mkdir qtlayoutcd qtlayout

STEP 3: create the file in the qtlayout directory.gedit qtlayout.cpp

STEP 4: Once the file has been saved, use the following commands to compile and execute the program..

> qmake-qt4 -project> qmake-qt4

> make> ./qtlayout

25

Page 26: Final Oss Lab Manual

STEP 5: Stop the program.PROGRAM:

//qtlayout.cpp#include <QtGui>

int main(int argc, char *argv[]){

QApplication app(argc, argv); QWidget window;//Create a label an a single line text box QLabel *label = new QLabel("Name:"); QLineEdit *lineEdit = new QLineEdit();

//Create a layout. Add the label and the lineedit to it.QHBoxLayout *layout = new QHBoxLayout();layout->addWidget(label);layout->addWidget(lineEdit);

//Apply the layout to the main window.//Since the widgets are part of the layout,//they are now children of the window. window.setLayout(layout); window.setWindowTitle("Window layout"); window.show();return app.exec();

}

OUTPUT:

RESULT: Thus the simple QT program is has been executed successfully.

EX.NO:7(C) SIMPLE GUI PROGRAMMING- SIGNALS AND SLOTSDATE: AIM: To write a QT program to create Window with Signals and slotsALGORITHM: STEP 1: Start the program. STEP 2: Create a new directory for the program.

mkdir qtsignalscd qtsignals

STEP 3: create three files in the qtsignals directory.communicate.hcommunicate.cppmain.cpp

STEP 4: Once the file has been saved, use the following commands to compile and execute the program..

> qmake-qt4 -project> qmake-qt4

> make

26

Page 27: Final Oss Lab Manual

> ./qtsignals STEP 5: Stop the program.PROGRAM:

> gedit communicate.h//communicate.h#include <QWidget>#include <QApplication>#include <QPushButton>#include <QLabel>class Communicate : public QWidget{//The Q_OBJECT macro causes the moc tool to initialise//code for signals and slots, run time type information//and dynamic property system

Q_OBJECTpublic:

Communicate(QWidget *parent = 0);//add a lot which allows widget communications private slots:

void add();private:

QLabel *label;

};○create the file in the qtsignals directory.

> gedit communicate.cpp//communicate.cpp#include "communicate.h"#include <QDesktopWidget>Communicate::Communicate(QWidget *parent)

: QWidget(parent){

resize(180, 140);QPushButton *plus = new QPushButton("+", this);plus->setGeometry(50, 40, 50, 30);label = new QLabel("0", this);label->setGeometry(120, 40, 20, 30);

//Connect the clicked event of the button to//the add method of the class

connect(plus, SIGNAL(clicked()), this, SLOT(add()));}void Communicate::add(){//Change the text displayed in the label int val = label-

>text().toInt();val++;label->setText(QString::number(val));

}

○create the file in the qtsignals directory.> gedit main.cpp

27

Page 28: Final Oss Lab Manual

/main.cpp#include "communicate.h"int main(int argc, char *argv[]){

QApplication app(argc, argv); Communicate window;window.setWindowTitle("Communicate");window.show();return app.exec();

}

OUTPUT:

RESULT: Thus the simple QT program is has been executed successfully.

EX.NO:8 VIRTUALISATION ENVIRONMENTDATE: AIM :

To develop Virtualisation environment (e.g., xen, kqemu or lguest) to test an applications, new kernels and isolate applications.ALGORITHM:Steps for Virtualization using QEMU and FreeDOS1. Download the fdbasecd.iso from www.freedos.org (or) from fosslab serverThe following steps should be followed from the directory where fdbasecd.iso is stored2. create virtual machine : # virtmanager &

3. Click on file connect to connect to localhost

28

Page 29: Final Oss Lab Manual

4. In the base menu, please rightclick on the localhost (QEMU) to create a new VM. Please name the VM as per your choice

5. In the next screen, select the Use ISO image option then click the Browse option.

6. In the next screen click the Browse Local option on the bottomleft section of the screen.

7. In the next screen please select the ISO image file of your own choice (Ubuntu, centos, fedora etc)8. After selecting the ISO file please select OS Type as Linux and Version as Generic 2.6.x kernel.9. In the next screen, please select the CPU and

RAM limits for the VM. By default they are 512M and one CPU

29

Page 30: Final Oss Lab Manual

10. In the next screen, please select the required size for the VM (By default 8GB)

11. In the next screen, by default no networking is selected without using a bridge.If required networking can be enabled for the VM by creating a bridge. Please click on Finish to start creating the machine. Once the machine is created, the same would be displayed on virtmanager screen and the VM can be started, stopped by selecting the VM and rightclicking to select options.

Result:Thus Virtualization is learnt by installing MS-DOS in virtual machine.

EX.NO:9 SETTING UP OF COMPLETE NETWORK INTERFACEDATE: AIM :

To set up Network Interface using 'ifconfig' command and the related system

30

Page 31: Final Oss Lab Manual

files.PROBLEM DESCRIPTION:

A Network interface is the point of interconnection between a computer and a privateor public network. A network interface is generally a network interface card (NIC). Gateway is a node that allows you to gain entrance into a network and vice versa. On the Internet the node which is the stopping point can be a gateway or a host node. A computer that controls the traffic your network or your ISP (Internet Service Provider) receives is a node.DNS (Domain name server), the system that automatically translates Internet addresses to the numeric machine addresses that computers use.Iptables is a user space application program provided by the Linux kernel firewall (implemented as different Netfilter modules) ,that allows us to configure the tables and the chains and rules it stores.P R O CE DU R E : 1. Configuring the network•Assign an IP address for the computer

# ifconfig eth0 192.168.x.y netmask 255.255.255.0 up• Adding a hub to the machine

# route add –net 192.168.0.0 netmask 255.255.255.0 eth0• To contact hosts outside the network if a machine with IP address 192.168.x.y is the gateway

# route add default gw 192.168.x.y eth0

2. Configuring an interface for multiple IP addresses

• To use multiple IP address on one Ethernet card copy the file named ifcfg-eth0 located in/etc/sysconfig/network-scripts directory

DEVICE="eth0"IPADDR="192.168.2.100" NETMASK="255.255.0.0" ONBOOT="yes"BOOTPROTO="none"

• Create a new file named ifcfg-eth0:0 in the same directory and paste the content.• Modify the file as the following

DEVICE="eth0:0"31

Page 32: Final Oss Lab Manual

IPADDR="192.168.2.101" NETMASK="255.255.0.0" ONBOOT="yes" BOOTPROTO="none"

• To add more IP address replace :0 with :1, :2, :3• Now restart the system to make it effective

#service network restart

3. Configuring the DNS

• Edit the network file present in the /etc/sysconfig/ directory

NETWORKING=yes FORWARD_IPV4=false HOSTNAME=yourname.collegename.com DOMAINNAME=collegename.com GATEWAY=192.168.x.y GATEWAYDEV=eth0

Where GATEWAYDEV is the network interface card that is attached to the network. The GATEWAY is the actual IP address of the gateway machine

4. Managing IPTABLES

32

Page 33: Final Oss Lab Manual

Start,stop and restart the iptables using the following commands:

#service iptables start#service iptables stop#service iptables restart

• To make iptables configured to start on boot, use the following command:

# chkconfig iptables on

• Check the status of the iptables#service iptables status

RESULT: Thus setting up of Network Interface using 'ifconfig' command and the related system files is done successfully.

33

Page 34: Final Oss Lab Manual

EX.NO:10 COMPILING SOFTWARE FROM SOURCE DATE: AIM :

To learn about the common build systems available in Linux and to use them.P ROCED U RE:

1. Make

Create a n e w d i r e c t o r y

> mkd i r g numa k e > c d g numake

Create a new file in the qthello directory.> gedit squareroot.c

// squareroot.c// A simple program that computes the square root of a number#include <stdio.h>#include <stdlib.h>#include <math.h>int main (int argc, char *argv[]){if (argc < 2)

{fprintf(stdout,"Usage: %s number\n",argv[0]);return 1;}double inputValue = atof(argv[1]);double outputValue = sqrt(inputValue);fprintf(stdout,"The square root of %g is %g\n",inputValue,outputValue);return 0;}

Test the program by compiling it once:

> gcc squareroot.c -o squareroot -lm> ./sqaureroot 49> The squ a re root of 49 i s 7

Create a makefile to compile the program

>gedit Makefile

# Commands start with TAB not spaces

Test the Makefile

34

Page 35: Final Oss Lab Manual

• Create a makefile to compile the program>gedit Makefile# Commands start with TAB not spacesCC = gcc CFLAGS= -g LDFLAGS = -lm all: squarerootsquareroot: squareroot.o squareroot.o: squareroot.cclean:rm -f squareroot squareroot.o• Test the Makefile

> makemake: Nothing to be done for `all'.> make cleanrm -f squareroot squareroot.o> makegcc -g -c -o squareroot.o squareroot.c gcc -lm squareroot.o -o squareroot> ./squareroot 49The square root of 49 is 7

2.Apache Ant

Create a new directory

> cd ../../> mkdir ant> cd ant> mkdir -p src/hello> gedit src/hello/HelloWorld.java

The Code:

package hello;public class HelloWorld{public static void main(String[] args)

35

Page 36: Final Oss Lab Manual

{System.out.println("Hello World");}}

Compile the program

> mkdir -p build/classes> javac -sourcepath src -d build/classes/ src/hello/HelloWorld.java> java -cp build/classes hello.HelloWorldHello World

Create a Ant bui l d s c ript

> g e dit bui l d. x ml The Cod e :

<project><target name="clean"><delete dir="build"/></target><target name="compile"><mkdir dir="build/classes"/><javac srcdir="src" destdir="build/classes"/></target><target name="jar"><mkdir dir="build/jar"/><jar destfile="build/jar/HelloWorld.jar" basedir="build/classes"><manifest><attribute name="Main-Class" value="hello.HelloWorld"/></manifest></jar></target><target name="run"><java jar="build/jar/HelloWorld.jar" fork="true"/></target></project>

36

Page 37: Final Oss Lab Manual

http://csetube.tk/

Now compile and run the program

>ant clean>ant compile jar run

RESULT:Thus the common build systems available in Linux is learnt to use and build successfully.

37