Friday 10 January 2014

Taskdef in Apache Ant

The 'taskdef' attribute can be used to add a task definition which would then be used in the existing project.

The taskdef tag is an important step you need to know, before I compose a post about automating deployments to tomcat.

It's syntax is similar to the typedef attribute.

Eg:

<taskdef name="start-tomcat" classname="org.apache.catalina.ant.StartTask" />

Observe how we set the classname attribute above.

Official information about Taskdef can be read here.

Accessing Tomcat Manager

If you deploy your web applications to Apache Tomcat, then you may want to know about accessing the Tomcat manager page.

Let's assume you already have downloaded Apache Tomcat. If not, please download the current stable version v7.x from the official download site.

Once you have downloaded Tomcat you have to set the environment variables.

Now in order to access the Tomcat Manager, go to the tomcat_home/conf directory { For instance /usr/temp/apache-tomcat-7.0.47/conf }.

Now edit the tomcat-users.xml file in Terminal. { vi tomcat-users.xml }. Scroll down and you'll observe the tags for roles and users.

Insert the following roles as follows :

  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-status"/>

Below the roles insert a new user named as 'admin' and define his roles in the following fashion :

<user username="admin" password="***" roles="admin-gui,manager-gui,manager-script"/>

Make sure to remove the comment tags <!-- and --> before roles and after the users block and save the file.

If you're not conversant with vi editor, I'll cover the topic about vi keyboard commands in another post.

For now, once the edits are made to the tomcat-users.xml, startup tomcat and open browser.

In the browser, type localhost:8080 { default port is 8080, but it can be modified if you want to. I'll cover this topic as well in a separate post. }. Then click the button Manager App on right. Check the below screenshot for reference.


Once you click Manager App, you'll prompted to enter the credentials. Enter the admin username and password which you specified in the tomcat-users.xml, to thereby access the manager. Here you can see the list of deployed applications. Individual applications can be started or stopped here. You can also check the server status here.


If you want to manually deploy a web application, you can choose the .war file and manually deploy it from this page. However, if you want to automate the deployment of a .war file using Apache Ant, I'll cover the topic in detail in another post. The post will contain information about copying the tomcat jars to ant home, defining tasks in build.xml to start, stop tomcat, deploy, undeploy an application. Stay tuned :)

Wednesday 8 January 2014

List all users and passwords in MySql on OSX

If you want to list all the users and their passwords in MySql on OSX, type the following on Terminal :

In the mysql prompt:

mysql> select user, password from mysql.user;

The above command will display the entire list of Mysql users and their encrypted passwords in a tabulated format.


Note that, since the default encryption is not considered safe enough, it is often advised to use MD5 or SHA1 encryption. We will cover that topic in another post.



Login to Mysql on OSX

This post assumes that you already have installed MySql on your machine. If haven't done it yet, please download the relevant platform version from the Official Mysql Download site.

In-order to logon and invoke the MySql prompt, type the following in Terminal :

mysql -u <username> -p

Enter password : <Type your password here>

Eg:

mysql -u IroncladWriter -p
Enter Pasword: ***

On a successful login, you get the following prompt -


Tuesday 7 January 2014

New York City subway romance

New York City as you know it, is always bustling with people - the tourists, the locals, the office peeps, the hipsters, the blue collared staff, the wall street guys, the cops. No matter where you go, you'll always bump into people.

However there are some folks who prefer peace and quiet over the hustle & bustle. For instance, the newly formed couples or the just-dating teens. Sometimes even you get this urge to get away from the crowd and commotion. Thats when, you really have to scout around looking for some private spots to get cosy with your loved ones.

Check out a smooth pacifying photo which captures this emotion. A couple just getting closer and strengthening their bond.


P.S : This was taken by me at the 42nd street Bryant Park subway station on one chilly night.

Eclipsed files in Clearcase

In Clearcase, sometimes files are not visible because they get eclipsed. This is because another object of the same name is being currently selected by the view.

This usually happens when the dynamic view is unable to delete the local copy of the checked out file even after you check it in. This view-private file thereby eclipses the file and is not visible.

One of the reasons why Clearcase is unable to delete the local copy is because some other 3rd party tool is accessing and locking the file.

Eclipsed files are denoted by the half-moon symbol as shown below:

Image courtesy : IBM


A detailed official IBM technote can be read here. Here you can read about recreating the steps for creating the eclipsed file scenario.

Count lines, words & characters of a file in Unix

On Unix and Linux machines, if you want to find out the word count, number of lines and the total number of characters used in a certain file, use the wc command in the following way.

Eg:

cat build.xml | wc

The output will be like 

9      26     297

Here, 9 is the number of lines, 26 is the number of words and 297 is the number of characters.
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker