Archive by Author

Change the SSH port on RedHat/Cent Os

Changing the SSH port of RedHat or Cent Os is not a tough job. Any administrator can change it by just editing sshd_config file and then reloading the service.

Step 1. Edit the sshd_config

vi /etc/ssh/sshd_config

Step 2. Change the Port No
You will find something like

#Port 22

Simply change this like

Port 2222

Step 3. Save and Exit
Step 4. Reload the New Configuration
service sshd reload
You are done and now you can test your new configuration using this command

ssh username@myhostnaname.com -p 2222

Precaution: Before logging out make sure your 2222 or the port you have set is open. Otherwise you will no be able to log in using that port. Check your firewall settings for this.

How to install Red5 on Cent Os 5.4

Red5 is open source flash server written in java supports streaming audio/video, recording client streams, shared objects, live stream publishing etc. Here I will describe in details how you can install Red5 on your CentOS. For this you will also need to install Java and Apache Ant.

Step 1. Install Java

RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.

yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel

Step 2. Install Ant

Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.

cd /usr/src
wget http://opensource.become.com/apache/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar zxvf apache-ant-1.7.1-bin.tar.gz
mv apache-ant-1.7.1/ /usr/local/ant

Step 3. Export Variables for Ant and Java

export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/lib/jvm/java
export PATH=$PATH:/usr/local/ant/bin
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip

Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.

echo ‘export ANT_HOME=/usr/local/ant’ >> /etc/bashrc
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ >> /etc/bashrc
echo ‘export PATH=$PATH:/usr/local/ant/bin’ >> /etc/bashrc
echo ‘export CLASSPATH=.:$JAVA_HOME/lib/classes.zip’ >> /etc/bashrc

Step 4. Download and Install RED5 Server

Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.

cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5
mv red5 /usr/local/
cd /usr/local/red5
ant prepare
ant dist

you will see a ton of lines, but you should get at last

BUILD SUCCESSFUL

that’s mean its install and now copy the conf directory from dist/ and test the red5 installation.

cp -r dist/conf .
./red5.sh

If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.

Step 5. Init Script

Now we will create init script for red5 to start, stop and restart easily.

vi /etc/init.d/red5

The init script code is below.

#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5

PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid

# Source function library
. /etc/rc.d/init.d/functions

[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5

RETVAL=0

case “$1″ in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG

fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac

exit $RETVAL

Now start the service

/etc/init.d/red5 start

check status

/etc/init.d/red5 status
red5 (pid XXXXX) is running…

again you can do stop, restart.

Step 6. Test

Now test the RED5 installation by opening following URL in browser

http://yourip:5080/

You will see Red5 test page.

Measurement in Software Engineering

1.    INTRODUCTION
Measurement is one of the key actions behind any quality product not only in software engineering but also in all industries. It is quite challenging for software engineers as software is different from any other products. Measure of a software entity is very important because through measuring we can find the defects in process and also estimate efforts and time.

2.    MEASURE IN SOFTWARE ENGINEERING

2.1    What is Measurement
According to Fenton, The process by which numbers and symbols are assigned to attributes of entities in the real world, as to describe them according to clearly defined rules.
Measure helps us to understand our world, interact with/control our surroundings and improve our lives. In fact any type of measurement gives us some idea which helps us in better decision making.

2.2    Why Measure in Software Engineering
We need measurement to understand, compare, control, decide and estimate [1].
Software now a day became inseparable part of our daily life. We can’t think of passing a single day without using software from driving cars to flying from one part of the world to another part, making a phone call to communication between NASA and space ship in Mars, managing personal finance to world economy.
Not only these, in the current world business of most of the large organizations are depends on the software. From daily attendance to payroll systems are now automated in most of the organization whether it’s business or non-profit organization. So, very simple mistake may result serious loss or destruction. The ability to deliver software on time, within budget, and with the expected functionality is critical to all software customers, who either directly or indirectly are all of us [2]. To achieve this measure of all the entities are very important in all phase so that a project manager can estimate effort both development and testing, analysis risk, calculate stability and reliability.

According to Lord Kelvin, “When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of meager and unsatisfactory kind.”

3.    MEASURE IN SDLC

3.1    Development Process
Software Development Life Cycle (SDLC) consisting of several phases such as requirement analysis, design, coding and testing. Every phase involves time and budget. So, proper measurement ensures higher quality of a successful product release. Software measures are used to quantify software products, software development resources, and the software development process. There are many characteristics of software and software projects that can be measured, such as size, complexity, reliability, quality, adherence to process, and profitability [2].

3.1.1    Requirement Analysis
In this phase measure is required in order to ensure the requirement analysis is done properly. Because if the requirement is not collected properly, and if the requirements are not valid and verified problem may arise in any of the next phase and then reverse engineering may be needed this will cause more time and money. In this phase we can estimate resource and time which is very important. Nominal scale can be used to measure in this phase of software development by classifying the objects from the requirement.

3.1.2    Design Phase
Design phase is very much important for any successful product development and delivery in time and budget. In this phase software engineers have to identify all the objects from the requirements and design a system which will be developed accordingly. So, in order to design a stable and reliable system, software designers have to concentrate on measuring future stability, quality of the system and also have to think of future enhancement or rework if needed. Nominal scale is preferred for measurement of classification of objects in this phase. And ratio scale can be used to estimate resource involvement based on developers quality and budget. Ordinal scale can be used to measure complexity of the system.

3.1.3    Coding Phase
Most of the time is needed in this phase of software development. So, to ensure fewer rework and defects in the system software engineers should do various measurements. In this phase developers do coding of the software in any standard language according to the design done in design phase. But as rework and more defects costs more money and time, so software engineers should do some measurement so that they can ensure higher quality of their code and system. This is not only in terms of defects but also the standard of codes and function points. To measure performance of a system developers can use ratio scale taking lines of code and memory usage.

3.1.4    Testing
This phase ensures that the developed system meets all functional requirements as intended. To do so systems needs to be properly tested and it is very common that some defects are found by testers and developers have to do some rework to fix those defects. In this phase absolute scale can be used to measure defects and ration scale can be used to predict probable release time and reliability of the system.

3.2    Difficulties
It is really very challenging for software engineers to measure certain attributes as most of those are no physical. It’s not a easy task to express virtual objects in terms of numbers but we try to related those and measurement is done in various phase of software development to help the project managers in better decision making as discussed in the earlier part of the report. If we take reliability of system as example, we can predict certain level but it’s not concrete. If anyone say the software is 85% reliable, it is said based on the defects found at that point and situation. It also depends on the perspective of the testers. So, it’s really difficult to measure certain attributes.
Again, to measure quality of a system is not absolute. It is always comparative. One product may be best among all the current products in the market but it’s not obvious that that product will remain best forever. From this point of view measurement is situation based and not absolute.

4.    CONCLUSION
Though measurement is counted as luxury in software engineering but we cannot ignore the importance of this. Because to ensure the delivery of any software product in targeted time and budget and with all intended functions requirements, measurement plays a vital role to estimate time and resource and also helps much in decision making. We had to prepare this report as part of course of Software Metrics but I have personally learnt a lot about the measurement of software entities and attribute which is really important to know as a software engineer. This assignment covers software measurement methods, models in various phase of software development life cycle.

5.    REFERENCES
[1]    N.E. Fenton, Software Metrics, A Rigorous & Practical Approach.
[2]    Linda M. Laird and M. Carol Brennan, Software Measurement and Estimation.

Learning is a Bridge between Work and Innovation

Literary, Learning is transmitting knowledge from one to another which helps one or a certain group of people enhancing knowledge, productivity, efficiency, skill and innovativeness. In the current competitive world an organization has to be innovative and bring new ideas time to time in order to sustain and maintain a steady growth. All those factors which are achieved by learning are really needed when an organization needs to adopt new technology or process in order to bring new product to the market.

Traditional concept of innovation in any particular organization was like one specific department will do research and generate new ideas. But this idea is replaced by approach of organizational learning. Organizations are now paying more and more attentions in generating new ideas, innovations and effectiveness. And for this now a day’s organizations are emphasizing on learning which is not out of work but also in the native working environment.

Learning could be done in two approaches. One is formal training which involves in transferring explicit knowledge from one head who knows to other head who does not know that. And another way of learning could be informal meeting, discussions, etc. The central issue in learning is becoming a practitioner not learning about practice. From the article we find according to Orr’s study this sort of learning going on in the process of and inseparable from work.  Again, Orr shows that the reps develop their understanding of machine, sometimes more than their employer either expects or allows, not in the training programs, but in the very conditions in their daily work.  So learning in the work place is the best approach of acquiring knowledge which is achieved by informal discussions and practice within the organization. This should be supported by the organization directly or indirectly and this is how community of practice is described. This does not only involve individual practice but also the organizational practice which results some learning of both explicit and tacit knowledge.  This often takes place in the coffee place or during lunch time through the informal discussion and sharing experiences with each other between the co-workers.

Learning increases sharing knowledge and experiences, ideas, understandings and also helps more in decision making. Though it takes time initially but once the process is started it makes the organizational members perform more efficiently in their regular work and also helps generating new ideas which lead them to innovation.

The concepts of learning especially organizational work by Mitzberg (1979), Miller (1986), Landry in 1992, Brown and Duguid (1991) are almost same and reflect the same principle that learning is a bridge between works an innovation.

Some sort of learning is not always possible by formal training, which can be experienced by informal learning. This sometimes leads to more innovativeness and creativity. Thus we can come to an end that working, learning and innovation are inter related with each other and learning while working sometimes proves as more fruitful.

Reference Article:

J. Seely‐Brown & P.Duguid “Organizational Learning and Communities of Practice: Toward a Unified View of Working, Learning and Innovation”

Sending Email From Your Spring Application

The Spring Framework provides a helpful utility library for sending email that shields the user from the specifics of the underlying mailing system and is responsible for low level resource handling on behalf of the client.

In my last project I have used spring mail functionality to send mail to the user. This is the simplest way so far I have found to send mail from spring application.

Let us also assume that there is a requirement stating that an email message with login information needs to be sent to the user.

Basic MailSender and SimpleMailMessage usage

Sample Controller:

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class ForgotPasswordFormController implements Controller{
private MailSender mailSender;
private SimpleMailMessage simpleMailMessage;

public void setMailSender(MailSender mailSender) {
this.mailSender = mailSender;
}
public void setSimpleMailMessage(SimpleMailMessage simpleMailMessage) {
this.simpleMailMessage = simpleMailMessage;
}

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception{
ModelAndView forgotPasswordMav = new ModelAndView();
forgotPasswordMav.setViewName(”forgot”);

if(request.getMethod().equalsIgnoreCase(”post”)){

// Do the business calculations…

// Create a thread safe “copy” of the template message and customize it

String email = request.getParameter(”email”);
SimpleMailMessage msg = new SimpleMailMessage(this.simpleMailMessage);
msg.setTo(email);
msg.setText(
“Dear user,”
+ “Your requested login information are following”
+ “Username :” + username
+ “Password :” + password
+ “, thank you for being with us ”
+ “Thanking,”
+ “Customer Care”);
try{
this.mailSender.send(msg);
status = 1;
}
catch(MailException ex) {
// simply log it and go on…
System.err.println(ex.getMessage());
}
}

return forgotPasswordMav;
}

}

Find below the bean definitions for the above code:

<bean name=”/forgotPassword.do” class=”com.mycompany.businessapp.ForgotPasswordFormController”>
<property name=”mailSender” ref=”mailSender”></property>
<property name=”simpleMailMessage” ref=”simpleMailMessage”></property>
</bean>
<bean id=”mailSender” class=”org.springframework.mail.javamail.JavaMailSenderImpl”>
<property name=”host” value=”mail.yourdomain.com”/>
</bean>

<!–
this is a template message that we can pre-load with default state
–>
<bean id=”simpleMailMessage” class=”org.springframework.mail.SimpleMailMessage”>
<property name=”from” value=”youremail@yourdomain.com” />
<property name=”subject” value=”Your Login Information” />
</bean>

To use this you will need the following two jars in your /WEB-INF/lib

mail.jar
activation.jar

To learn more or other ways of sending mail from spring application you can visit the following link:
Click Here

Itegrating DWR (Direct Web Remoting) with Spring

Hi Springers, I have used DWR (Direct Web Remoting) in my last project which was pretty interesting and I want to share the simplest way of using DWR with spring application. Download the latest version of dwr.jar from here. And put it in the /WEB-INF/lib folder. I have used DWR 2.0.5.

Add the following lines in your web.xml

<servlet>
  <servlet-name>dwr-invoker</servlet-name>
  <display-name>DWR Servlet</display-name>
  <servlet-class>
    org.directwebremoting.servlet.DwrServlet
  </servlet-class>
  <init-param>
     <param-name>debug</param-name>
     <param-value>true</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>dwr-invoker</servlet-name>
  <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

Now create a dwr.xml in the WEB-INF folder alongside web.xml and add the following line in that file.

<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
    "http://getahead.org/dwr/dwr20.dtd">

<dwr>
  <allow>
    <create creator="new" javascript="JDate">
      <param name="class" value="java.util.Date"/>
    </create>
    <create creator="new" javascript="Demo">
      <param name="class" value="your.java.Bean"/>
    </create>
  </allow>
</dwr>

To check go to the following URL.

http://localhost:8080/[YOUR-WEBAPP]/dwr/

You should see a page showing you the classes that you’ve selected.

To learn detail about DWR please visit the documentation site of DWR.

Restoring Default Ubuntu Panel

This is for the newbies in the Ubuntu Community. Sometimes we want to configure our panels on Ubuntu to give a nicer look. And the newbies often fail to do that as they want and may want to restore the default panel settings. Restoring the default panel setting on Ubuntu is pretty simple. Just run the following command in the terminal and you will get your default Ubuntu panels back.

sudo debconf gnome-panel

But this is not a permanent solution. To permanently enable your default panel configuration enter the following commands in the terminal sequentially.

gconftool –recursive-unset /apps/panel
rm -rf ~/.gconf/apps/panel
pkill gnome-panel

Enjoy!!

N.B. Don’t worry if any of the command removes all your panel. The next command will restore it to default configuration.

How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu (8.04 / 8.10)

This is for the newbies in the world of Ubuntu. Use the following steps to install LAMP (Linux, Apache, MySQL and PHP) in Ubuntu.

  • Open up the Terminal (Applications > Accessories > Terminal).
  • Run the following command to install Apache

    $sudo apt-get install apache2

  • To test Apache open up any web browser and then enter the following into the web address:

    http://localhost/

  • Now run the following command in the terminal to install PHP

    $sudo apt-get install php5 libapache2-mod-php5

  • In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:

    $sudo /etc/init.d/apache2 restart

  • In order to test PHP, in the terminal copy/paste the following line:

    $sudo gedit /var/www/testphp.php

  • Copy/Paste this line into the phptest file: <?php phpinfo(); ?>
  • Save and close the file.
  • http://localhost/testphp.php
  • Once again open up the amazing Terminal and then copy/paste this line:

    $sudo apt-get install mysql-server

  • This is where things may start to get tricky. Begin by typing the following into Terminal:

    $mysql -u root -p

  • Following that copy/paste this line:

    $mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’);

  • We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:

    $sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

  • After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:

    $sudo gedit /etc/php5/apache2/php.ini

  • Now we are going to have to uncomment the following line by taking out the semicolon (;). ;extension=mysql.so To look like this: extension=mysql.so

Now just restart Apache and you are all set!

$sudo /etc/init.d/apache2 restart

We are ready to start code in PHP using MySQL for database and Apache as HTTP server in Ubuntu!!!

Is Keyboard not working properly in Ubuntu 8.10?

Recently I have updated my Ubuntu machine at office from 8.04 (Hardy) to 8.10 (Intrepid Ibex). Surprisingly my keyboard was not working properly specially the arrow keys, HOME and END keys. Then I searched through google and found a quick solution. That I am sharing here to help others who may face this problem.
Just run the following command in the terminal all keys of your keyboard will work.

$ setxkbmap -model evdev

Thanking everyone and welcomed to share.

NB. This is not a permanant solution. But works for a single login. After restarting it will need to run the command again.

How to install or add PHP GD support in Ubuntu

PHP is mainly a server side language which renders the code at server and throws the output to the client end through Apache or any other HTTP server. So, being a newbie we often suffer from GD support in Ubuntu. This are the following steps to install or add PHP GD support in Ubuntu.

$ apt-get install php5-gd
OR
$ sudo apt-get install php5-gd
$ /etc/init.d/apache2 restart

Now PHP GD support is ready to work.