A sample Ant build script that builds a WAR file – Guide

ant-build-script-war-file

A sample Ant build script that builds a WAR file

<project name=”MyWebApplication” basedir=”..” default=”install”>

<!– project-specific variables –>
<property name=”jsp.dir.name” value=”myapp” />
<property name=”package.name” value=”${jsp.dir.name}.war” />
<property name=”webapp.dir” value=”/Users/al/tomcat-6.0.16/webapps” />

<property environment=”env” />
<property name=”build.dir” value=”build” />
<property file=”${build.dir}/build.${env.HOSTNAME}” />

<property name=”lib.dir” value=”lib” />
<property name=”pages.dir” value=”pages” />
<property name=”src.dir” value=”src” />
<property name=”src.tests.dir” value=”src-tests” />
<property name=”resources.dir” value=”resources” />
<property name=”dest.dir” value=”target” />

<!– put everything in a temp folder with the right structure during the build –>
<property name=”temp.dir” value=”temp” />
<property name=”temp.dir.web-inf” value=”${temp.dir}/WEB-INF” />
<property name=”temp.dir.lib” value=”${temp.dir.web-inf}/lib” />
<property name=”temp.dir.classes” value=”${temp.dir.web-inf}/classes” />
<property name=”temp.dir.meta-inf” value=”${temp.dir}/META-INF” />

<property name=”package.file” value=”${dest.dir}/${package.name}” />

<path id=”build.class.path”>
<fileset dir=”lib”>
<include name=”**/*.jar” />
</fileset>
</path>

<target name=”clean”>
<delete>
<fileset dir=”${dest.dir}” includes=”**/*”/>
</delete>
<delete dir=”${temp.dir}” />
<delete dir=”${temp.dir.classes}” />
<delete dir=”${temp.dir.meta-inf}” />
<delete dir=”${temp.dir.web-inf}” />
</target>

<target name=”prepare” depends=”clean”>
<mkdir dir=”${dest.dir}” />
<mkdir dir=”${temp.dir}” />
<mkdir dir=”${temp.dir.lib}” />
<mkdir dir=”${temp.dir.meta-inf}” />
<mkdir dir=”${temp.dir.web-inf}” />
<mkdir dir=”${temp.dir.classes}” />
</target>

<!– COMPILE –>
<target name=”compile” depends=”prepare”>
<echo>=== COMPILE ===</echo>
<echo>Compiling ${src.dir} files …</echo>
<javac debug=”on” srcdir=”${src.dir}” destdir=”${temp.dir.classes}” includes=”**/*”>
<classpath refid=”build.class.path” />
</javac>

<!– compile files on the src-tests path –>
<echo>Compiling ${src.tests.dir} files …</echo>
<javac debug=”on” srcdir=”${src.tests.dir}” destdir=”${temp.dir.classes}” includes=”com/**”>
<classpath refid=”build.class.path” />
</javac>
</target>

<!– PACKAGE –>
<target name=”package” depends=”compile”>
<echo>=== PACKAGE ===</echo>

<!– copy the config files –>
<copy file=”${resources.dir}/MANIFEST.MF” tofile=”${temp.dir.meta-inf}/MANIFEST.MF” overwrite=”true” />
<copy file=”${resources.dir}/web.xml” tofile=”${temp.dir.web-inf}/web.xml” overwrite=”true” />
<copy file=”${resources.dir}/managed-beans.xml” tofile=”${temp.dir.web-inf}/managed-beans.xml” overwrite=”true” />
<copy file=”${resources.dir}/navigation-rules.xml” tofile=”${temp.dir.web-inf}/navigation-rules.xml” overwrite=”true” />

<copy todir=”${temp.dir.classes}”>
<fileset dir=”${src.dir}”>
<include name=”**/*.xml”/>
<include name=”**/*.xsl”/>
</fileset>
</copy>

<!– with all resources in place, create the war file –>
<war destfile=”${package.file}” webxml=”${temp.dir.web-inf}/web.xml” basedir=”${temp.dir}”>
<fileset dir=”${pages.dir}”/>
<lib dir=”${lib.dir}” />
<classes dir=”${temp.dir.classes}” />
</war>
</target>

<!– JUST DEPLOY JSP’s –>
<target name=”jsps”>
<echo>=== DEPLOY JSP’S ===</echo>
<!– i’m trying to be explicit about what i put out there –>
<copy todir=”${webapp.dir}/${jsp.dir.name}”>
<fileset dir=”${pages.dir}”>
<include name=”**/*.jsp”/>
<include name=”**/*.html”/>
<include name=”**/*.css”/>
<include name=”**/*.gif”/>
<include name=”**/*.jpg”/>
<include name=”**/*.png”/>
<include name=”**/*.js”/>
</fileset>
</copy>
</target>

<!– INSTALL –>
<target name=”install” depends=”package”>
<echo>=== INSTALL ===</echo>
<copy file=”${package.file}” tofile=”${webapp.dir}/${package.name}” overwrite=”true” />
</target>

</project>

Tagged : / / / / / / / / / / / / / / / / /

Windows XP/2000 Commands & Tools | Windows XP Command-line Reference

windows-xp-2000-commands-tools

Here’s the ultimate Windows XP/2000 command list that will make any Linux user feel at home at the command prompt. A lot of these commands are intended for administrating a network, but they are great for savvy home users as well.  We even listed which OS you need for these commands.

Many thanks to the digg users who ‘dugg’ our site and care to leave comments of helpful commands that we have left out!

  • at (windows XP/2000)
    Scheduling utility.
  • bootcfg (XP only)
    This utility allows you to set up your boot options, such as your default OS and other loading options.
  • cacls (XP, 2000, & NT4.0)
    Changes the ACLs (security Settings) of files and folders. Very similar to chmod in Linux. 
  • comp (XP & 2000)
    This utility is very similar to diff in Linux.  Use the /? switch to get examples of command usage.
  • contig (works with NT4.0 and newer)
    A great defrag utility for NTFS partitions.
  • control (XP only) – unpublished!
    Allows you to launch control panel applets from the command line. 
    control userpasswords2, for example will launch a helpful local user admin utility.
  • defrag (XP only – NT4.0 and Win2k use contig)
    Yes, XP comes with a command line disk defrag utility. If you are running Win2k or NT4.0 there is still hope. Contig is a free defrag program that I describe on the defrag page.
  • diskpart (XP only)
    Use this command to manage your disk partitions.  This is the text version for the GUI Disk Manager.
  • driverquery (XP only)
    Produces a list of drivers, their properties, and their versions. Great for computer documentation.
  • eudcedit (XP only) – unpublished!
    Private Character editor.  Yes with this program built into Windows XP you can create your own font!
  • fsutil (XP only) – unpublished!
    This is a utility with a lot of capability.  Come back soon for great examples.
  • getmac (XP & 2000)
    This command gets the Media Access Control (MAC) address of your network cards.
  • gpresult (XP & 2000)
    This generates a summary of the user settings and computer group policy settings.
  • gpupdate (XP only)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.
  • ipconfig (XP, 2000 & NT4.0)
    This handy tool displays IP settings of the current computer and much more.
  • MMC (XP, 2000 & NT4.0) – Microsoft Management Console
    This is the master tool for Windows, it is the main interface in which all other tools use starting primarily in Windows 2000 and newer systems.
  • more
    Utility used to display text output one screen at a time. Ex. more c:\windows\win.ini
  • msconfig (XP only)
    The ultimate tool to change the services and utilities that start when your Windows machine boots up. You can also copy the executable from XP and use it in Win2k.
  • msinfo32 (XP &smp; 2000)
    An awesome diagnostic tool. With it you can get a list of running processes, including the residing path of the executable (great for manually removing malware) and get detailed information about hardware and system diagnostics.
  • narrator (XP only)
    Turns on the system narrator (can also be found in accessibility options in control panel).  Will will allow your computer to dictate text to you.
  • netsh (XP & 2000)
    A network configuration tool console.  At the ‘netsh>’ prompt, use the ‘?’ to list the available commands and type “exit” to get back to a command prompt.
  • nslookup (all)
    A DNS name resolution tool.
  • openfiles (XP Only)
    Allows an administrator to display or disconnect open files in XP professional. Type “openfiles /?” for a list of possible parameters.
  • Pathping (XP & 2000)
    A cross between the ping and traceroute utilities. Who needs Neotrace when you can use this? Type “pathping <ip address>” and watch it go.
  • recover (XP & 2000)
    This command can recover readable information from a damaged disk and is very easy to use.
  • reg (XP & 2000)
    A console registry tool, great for scripting Registry edits.
  • sc (XP & 2000)
    A command line utility called the Service Controller.  A power tool to make service changes via a logon/logoff or startup/shutdown script.
  • schtasks (XP only)
    A newer version of the AT command.  This allows an administrator to schedule and manage scheduled tasks on a local and remote machines.
  • secedit (XP & 2000)
    Use this utility to manually apply computer and user policy from your windows 2000 (or newer) domain.  Example to update the machine policy: secedit /refreshpolicy machine_policy /enforce
    To view help on this, just type secedit.
    NOTE: In Windows XP SP1 and news, this command is superceded by: gpupdate /force
  • sfc (XP & 2000)
    The system file checker scans important system files and replaces the ones you (or your applications) hacked beyond repair with the real, official Microsoft versions.
  • shutdown (XP & 2000)
    With this tool, You can shut down or restart your own computer, or an administrator can shut down or restart a remote computer.
  • sigverif (XP only)
    Microsoft has created driver signatures. A signed driver is Microsoft tested and approved. With the sigverif tool you can have all driver files analyzed to verify that they are digitally signed. Just type ‘sigverif’ at the command prompt.
  • systeminfo (XP only)
    Basic system configuration information, such as the system type, the processor type, time zone, virtual memory settings, system uptime, and much more.  This program is great for creating an inventory of computers on your network.
  • sysedit (XP/2000)
    System Configuration File Editor.  An old tool that was very handy for the Windows 9X days.  msconfig is what you want to use now.
  • tasklist (XP pro only)
    Tasklist is the command console equivalent to the task manager in windows. It is a must have when fighting scumware and viruses. Try the command:
    tasklist /svc
    to view the memory resources your services take up.
  • taskkill (XP only)
    Taskkill contains the rest of the task manager functionality.  It allows you to kill those unneeded or locked up applications.
  • tree (XP & 2000)
    An amazing experience everyone should try!  This command will provide a ‘family tree’ style display of the drive/folder you specify.
  • WMIC (XP & 2000)
    Windows Management Instrumentation Command tool.  This allows you to pull an amazing amount of low-level system information from a command line scripting interface.
Tagged : / / / / / / / / / / / / / / / / /

VI/VIM editor Commands | VI/VIM editor commands reference | Cheat Sheet

vi-vim-editor-commands

  • what will happen ?

“man ls |col -b > ” will give the text file same as man ls.

  • what is VI-editor ?

While in vi you can run AIX commands without exiting the editing session. The! creates a
shell to execute the command that follows.
1. :!ls will create a shell
2. All files in the current directory are listed. Press return to exit the shell and return to the
vi session or…
3. While still in command mode, issue the :r snacks command
4. The contents of snacks, in this case, are read into the vi file. By default, it will appear
after the current line.
If you need to run a series of commands without returning to vi after the first command is
executed, enter :sh. When you have run all the commands, press to exit the shell
and return to vi.

  • VI Options:-

vi has many modes of operation. Some of these will affect the way text is presented, while
others will make editing easier for novice users.
:set all display all settings
:set display settings different than the default
:set ai sets autoindent on
:set noai turns autoindent mode off
:set nu enables line numbers
:set nonu turns line numbers off
:set list displays non-printable characters
:set nolist hides non-printable characters
:set showmode shows the current mode of operation
:set noshowmode hides mode of operation
:set ts=4 sets tabs to 4-character jumps
:set ic ignores case sensitivity
:set noic case sensitive

  • Search

/word     Search “word” from top to bottom
?word     Search “word” from bottom to top
/jo[ha]n     Search “john” or “joan”
/\< the     Search “the”, “theatre” or “then”
/the\>     Search “the” or “breathe”
/\     Search “the”
/\     Search all words of 4 letters
/\/     Search “fred” but not “alfred” or “frederick”
/fred\|joe     Search “fred” or “joe”
/\     Search exactly 4 digits
/^\n\{3}     Find 3 empty lines
:bufdo /searchstr/     Search in all open files

  • Replace

:%s/old/new/g     Replace all occurences of “old” by “new” in file
:%s/old/new/gw     Replace all occurences with confirmation
:2,35s/old/new/g     Replace all occurences between lines 2 and 35
:5,$s/old/new/g     Replace all occurences from line 5 to EOF
:%s/^/hello/g     Replace the begining of each line by “hello”
:%s/$/Harry/g     Replace the end of each line by “Harry”
:%s/onward/forward/gi     Replace “onward” by “forward” , case unsensitive
:%s/ *$//g     Delete all white spaces
:g/string/d     Delete all lines containing “string”
:v/string/d     Delete all lines containing which didn’t contain “string”
:s/Bill/Steve/     Replace the first occurence of “Bill” by “Steve” in current line
:s/Bill/Steve/g     Replace “Bill” by “Steve” in current line
:%s/Bill/Steve/g     Replace “Bill” by “Steve” in all the file
:%s/\r//g     Delete DOS carriage returns (^M)
:%s/\r/\r/g     Transform DOS carriage returns in returns
:%s#]\+>##g     Delete HTML tags but keeps text
:%s/^\(.*\)\n\1$/\1/     Delete lines which appears twice
Ctrl+a     Increment number under the cursor
Ctrl+x     Decrement number under cursor
ggVGg?     Change text to Rot13

 

  • Case

Vu     Lowercase line
VU     Uppercase line
g~~     Invert case
vEU     Switch word to uppercase
vE~     Modify word case
ggguG     Set all text to lowercase
:set ignorecase     Ignore case in searches
:set smartcase     Ignore case in searches excepted if an uppercase letter is used
:%s/\<./\u&/g     Sets first letter of each word to uppercase
:%s/\<./\l&/g     Sets first letter of each word to lowercase
:%s/.*/\u&     Sets first letter of each line to uppercase
:%s/.*/\l&     Sets first letter of each line to lowercase

  • Read/Write files

:1,10 w outfile     Saves lines 1 to 10 in outfile
:1,10 w >> outfile     Appends lines 1 to 10 to outfile
:r infile     Insert the content of infile
:23r infile     Insert the content of infile under line 23

  • File explorer

:e .     Open integrated file explorer
:Sex     Split window and open integrated file explorer
:browse e     Graphical file explorer
:ls     List buffers
:cd ..     Move to parent directory
:args     List files
:args *.php     Open file list
:grep expression *.php     Returns a list of .php files contening expression
gf     Open file name under cursor

  • Interact with Unix

:!pwd     Execute the “pwd” unix command, then returns to Vi
!!pwd     Execute the “pwd” unix command and insert output in file
:sh     Temporary returns to Unix
$exit     Retourns to Vi

  • Alignment

:%!fmt     Align all lines
!}fmt     Align all lines at the current position
5!!fmt     Align the next 5 lines

  • Tabs

:tabnew     Creates a new tab
gt     Show next tab
:tabfirst     Show first tab
:tablast     Show last tab
:tabm n(position)     Rearrange tabs
:tabdo %s/foo/bar/g     Execute a command in all tabs
:tab ball     Puts all open files in tabs

  • Window spliting

:e filename     Edit filename in current window
:split filename     Split the window and open filename
ctrl-w up arrow     Puts cursor in top window
ctrl-w ctrl-w     Puts cursor in next window
ctrl-w_     Maximise current window
ctrl-w=     Gives the same size to all windows
10 ctrl-w+     Add 10 lines to current window
:vsplit file     Split window vertically
:sview file     Same as :split in readonly mode
:hide     Close current window
:only     Close all windows, excepted current
:b 2     Open #2 in this window

  • Auto-completion

Ctrl+n Ctrl+p (in insert mode)     Complete word
Ctrl+x Ctrl+l     Complete line
:set dictionary=dict     Define dict as a dictionnary
Ctrl+x Ctrl+k     Complete with dictionnary

  • Marks

mk     Marks current position as k
‘k     Moves cursor to mark k
d’k     Delete all until mark k
Abbreviations
:ab pr printf(“This is a Demo Ver \n”);    Define pr as abbreviation of printf(“This is a Demo Ver \n”);

  • Text indent

:set autoindent     Turn on auto-indent
:set smartindent     Turn on intelligent auto-indent
:set shiftwidth=4     Defines 4 spaces as indent size
ctrl-t, ctrl-d     Indent/un-indent in insert mode
>>     Indent
<<     Un-indent

  • Syntax highlighting

:syntax on     Turn on syntax highlighting
:syntax off     Turn off syntax highlighting
:set syntax=perl     Force syntax highlighting

  • How to Exit

:q[uit]     Quit Vim. This fails when changes have been made.
:q[uit]!     Quit without writing.
:cq[uit]     Quit always, without writing.
:wq     Write the current file and exit.
:wq!     Write the current file and exit always.
:wq {file}     Write to {file}. Exit if not editing the last
:wq! {file}     Write to {file} and exit always.
:[range]wq[!]     [file] Same as above, but only write the lines in [range].
ZZ     Write current file, if modified, and exit.
ZQ     Quit current file and exit (same as “:q!”).

  • Editing a File

:e[dit]     Edit the current file. This is useful to re-edit the current file, when it has been changed outside                 of Vim.
:e[dit]!     Edit the current file always. Discard any changes to the current buffer. This is useful if you want                 to start all over again.
:e[dit] {file}     Edit {file}.
:e[dit]! {file}     Edit {file} always. Discard any changes to the current buffer.
gf     Edit the file whose name is under or after the cursor. Mnemonic: “goto file”.

  • Inserting Text

a     Append text after the cursor [count] times.
A     Append text at the end of the line [count] times.
i     Insert text before the cursor [count] times.
I     Insert text before the first non-blank in the line [count] times.
gI     Insert text in column 1 [count] times.
o     Begin a new line below the cursor and insert text, repeat [count] times.
O     Begin a new line above the cursor and insert text, repeat [count] times.

  • Inserting a file

:r[ead] [name]     Insert the file [name] below the cursor.
:r[ead] !{cmd}     Execute {cmd} and insert its standard output below the cursor.
 

Tagged : / / / / / / / / / / / / / / / / / / / / / / / / / / / / /