gsh – Run linux commands on many other linux server at once


gsh – Run linux commands on many other linux server at once

Group Shell (also called gsh) is a remote shell multiplexor. It lets you control many remote shells at once in a single shell. Unlike other commands dispatchers, it is interactive, so shells spawned on the remote hosts are persistent.

GSH is a pluggable version of DSH (Distributed Shell) written in Python. Both a module and a command-line tool for running a shell command over multiple machines are included. GSH can be extended by adding new host loaders as well as hooking into various stages of the runtime.

It requires only a SSH server on the remote hosts, or some other way to open a remote shell.
gsh allows you to run commands on multiple hosts by adding tags to the gsh command.

e.g > gsh tag “remote command”

Important things to remember:
/etc/ghosts contains a list of all the servers and tags. gsh is a lot more fun once you’ve set up ssh keys to your servers

SYSTEMS is a combination of ghost macros. See ghosts(1).

CMD is the command to run
-h, –help Display full help
-d, –debug Turn on exeuction debugging reports
-h, –no-host-prefix Does not prefix output lines with the host name
-s, –show-commands Displays the command before the output report
-n, –open-stdin Leaves stdin open when running (scary!)
-l, –user USER SSH’s to the host as user USER
-r, –run-locally Run commands locally (replaces $host with host)
-o, –self-remote Run locally instead of over SSH for local host
-V, –version Report the version and exit

You set up a /etc/ghosts file containing your servers in groups such as web, db, RHEL4, x86_64, or whatever (man ghosts) then you use that group when you call gsh.

How to run the gsh?
> gsh linux “cat /etc/redhat-release; uname -r”

You can also combine or split ghost groups, using cpanel+vps or web-RHEL4, for example.

Here’s an example /etc/ghosts file:
# Machines
 # hostname OS-Version Hardware OS cp security debian6 baremetal linux plesk iptables centos5 vps linux cpanel csfcluster debian7 baremetal linux plesk iptables centos6 vps linux cpanel csfcluster centos6 vps linux cpanel csfcluster centos6 vps linux nocp denyhosts debian6 baremetal linux plesk iptables centos6 baremetal linux cpanel csf centos5 vps linux cpanel csf

Reference url

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

Clover and Maven working with Distributed Applications


1.       Configure maven clover plugin.

2.       Build the all components with clover enabled.

3.       Deploy the clover enabled build to test server.

4.       Run the tests.

5.       Create & Review the Code Coverage Report.

Configure Maven Clover Plugin

Configure the maven plugin in pom.xml .If you are having multi module projects; you can configure the plugin in parent-pom instead of modifying each module’s pom xml.

Build all components with clover enabled.

Run the following command.


  “mvn -U clover2:setup package clover2:aggregate


                If you got something like this

[INFO] Loaded from: C:\Documents and Settings\Administrator\.m2\repository\com\cenqua\clover\clover\2.6.3\clover-2.6.3.jar

[INFO] Clover: Commercial License registered to ABC Corporation.

[INFO] Creating new database at ‘C:\p4_depot\trunk\4A\target\clover\clover.db’.

[INFO] Processing files at 1.5 source level.

[INFO] Clover all over. Instrumented 5 files (1 package).

[INFO] Elapsed time = 0.532 secs. (9.398 files/sec, 812.03 srclines/sec)

Congratulation, you get clover work with your source!!


Deploy the clover enabled build to test server.

Deploy the Clover enabled build to the server. The same process as normal

Copy the Clover registry file to the appropriate directory on each of the test servers


The registry file is the DB file create during compile, defined by initstring parametersclover‐setup task, this needs to occur after the Clover build is complete, and before you run your tests


Background: the Clover initstring


FileName: xxx.db

At build time, Clover constructs a registry of your source code, and writes it to a file at the location specified in the Clover initstring. When Clover‐ instrumented code is executed (e.g. by running a suite of unit tests), Clover looks in the same location for this registry file to initialise itself. Clover then records coverage data and writes coverage recording files next to the registry file during execution

Notes: gives the folder contains the registry file full control permissions


Recommended Permissions

Clover requires access to the Java system properties for runtime configurations, as well as read write access to areas of the file system to read the Clover coverage database and to write coverage information. Clover also uses a shutdown hook to ensure that it flushes any as yet unflushed coverage information to disk when Java exits. To support these requirements, the following security

permissions are recommended:


grant codeBase “file:/path/to/clover.jar” {

permission java.util.PropertyPermission “*”, “read”;

permission “<>”, “read, write”;

permission java.lang.RuntimePermission “shutdownHooks”;



Grant Permissions to clover.jar

Edit the java.policy file of the java runtime on the test server



Copy clover.jar and license file to the java runtime class path of the test servers




Run the test suite

Run the test suite as normal. Either automation test case or manual test case.


Create Code Coverage Report

Copy the coverage recording files to build machine.


Once test execution is complete, you will need to copy the coverage recording files from each remote machine to the initstring path on the build machine in order to generate coverage reports.


Background: CoverageRecording Files


Filename:xxx.dbHHHHHHH_TTTTTTTTTT or clover.dbHHHHHHH_TTTTTTTTTT.1 (where HHHHHHH and TTTTTTTTTT are both hex strings)

CoverageRecording files contain actual coverage data. When running instrumented code, Clover creates one or more Coverage Recorders. Each Coverage Recorder will write one CoverageRecording file. The number of Coverage Recorders created at runtime depends the nature of the application you are Clovering. In general a new Coverage Recorder will be created for each new ClassLoader instance that loads a Clovered class file. The first hex number in the filename (HHHHHHH) is a unique number based on the recording context. The second hex number (TTTTTTTTTT) is the timestamp (ms since epoch) of the creation of the Clover Recorder. CoverageRecording files are named this way to try to minimise the chance of a name clash. While it is theoretically possible that a name clash could occur, in practice the chances are very small.

CoverageRecording files are written during the execution of Clover‐instrumented code. CoverageRecording files are read during report generation or coverage browsing.


Run the generating report goal to create the report.

                                “mvn clover2:clover”


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

Running MSBuild 4.0 and MSBuild 3.5 on Continuous Integration


With Visual Studio 2010 RC released recently, we jumped on the release and began to code with VS2010.  One issue that popped up was that now all builds were targeting MSBuild 4.0.

That doesn’t seem to be a big problem until our CruiseControl CI server kicked in, downloaded our updated code and failed building the upgraded projects.

Fortunately there is a very quick solution to this little problem.  There are a couple of requirements.

1. You need to have VS2010 RC installed somewhere
2. You need to download the .Net Framework 4.0 (I recommend the full version and not just the Client Profile, it ensures you don’t miss anything)

To fix, do the following:

1. download and install the .Net Framework 4.0 on the CI server (then restart the server)
2. on the computer where VS2010 RC is installed go to the following path:
3. copy the v10.0 folder located in that directory into the CI server at the same path (or wherever our MSbuild path is on the CI server)
4. Once that is done, edit the ccnet.config file at the tag and change it to the new .Net 4.0 Framework installed (you should only need to change the section “\v3.5\” to “\v4.0.xxxxx\”

Hope this helps

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

How to run Remote Desktop Console by using command line?

How to run Remote Desktop Console using command line
If you may want to run Desktop Console from a batch file, for example RDC over VPN, you can use mstsc /v:servername /console command.


Creates connections to terminal servers or other remote computers, edits an existing Remote Desktop Connection (.rdp) configuration file, and migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.


mstsc.exe {ConnectionFile | /v:ServerName[:Port]} [/console] [/f] [/w:Width /h:Height]
mstsc.exe /edit”ConnectionFile”
mstsc.exe /migrate


Specifies the name of an .rdp file for the connection.
Specifies the remote computer and, optionally, the port number to which you want to connect.

Connects to the console session of the specified Windows Server 2003 family operating system.

Starts Remote Desktop connection in full-screen mode.

/w:Width /h:Height
Specifies the dimensions of the Remote Desktop screen.

Opens the specified .rdp file for editing.

Migrates legacy connection files that were created with Client Connection Manager to new .rdp connection files.

* You must be an administrator on the server to which you are connecting to create a remote console connection.
* default.rdp is stored for each user as a hidden file in My Documents. User created .rdp files are stored by default in My Documents but can be moved anywhere.

To connect to the console session of a server, type:
mstsc /console

To open a file called filename.rdp for editing, type:
mstsc /edit filename.rdp

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

Ant Script with Shell script, How to run shell script from Ant Script?


Ant Script with Shell script
How to set files Permission in Ant | How to set files Permission in Unix | Set files Permission in Ant in Unix Environment


Ant Script to Replace some character in any files


How to run shell script using ant/
To Remove Some Special Character from Files
for name in `find PWD -type f`
if [ -f $name ]; then
tr -d “\015” ${name}XXXYYYZZZ
mv ${name}XXXYYYZZZ $name
echo “$name updated”


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

Running Native Programs in Ant


Running Native Programs in Ant

Ant, while extremely powerful and flexible, can’t always offer everything you want to do. If this

is the case, you can use the <exec> task, which can run any command-line program.

 The <exec> Task’s Attributes

Attribute Description
appends Sets whether to append the output to the end of a file or overwrite the contents of the file (used in conjunction with output). The default is false.
dir The directory from where the program will be run. The default is null.
error The file to which you want to redirect error messages. The default is the setting in output.
Errorproperty The property where Ant will store error messages. The default is blank.
Executable The command you want to execute. This should be the name of the command and should not be accompanied by any arguments. You specify them with nested <arg> elements. This attribute is required.
failifexecutionfails Tells Ant whether to stop the build if the command fails to start at all. The default is true.
failonerror Tells Ant whether to stop the build if the command exits with a return code other than 0. The default is false.
input The name of a file that will be the input to this command. You can specify only one of input and inputstring. The default is standard input from the console. In addition, you cannot obtain standard input if you set spawn to true.
inputstring A string that will be the input to this command. You can specify only one of input and inputstring. The default is standard input from the console. In addition, you cannot obtain standard input if you set spawn to true.
logError Tells Ant to write error messages to the Ant log files. The error messages will not appear in any output location that you have set. Ant ignores this attribute if you set error or errorproperty. The default is false.
Newenvironment Tells the program to ignore old environment variables if new ones are specified. The default is false.
os Ant will execute the command only if it is running on an operating system in this list. Ant uses String.indexOf() < 0 to see whether the operating system matches anything in this list, so you can specify the operating systems in any format you like, even a continuous string with no separators. The default is to always run the command.
output The file to which you want to redirect output. The default is standard out.
outputproperty The property where Ant will store the output of this command (including error messages unless otherwise redirected). The default is blank.
resolveexecutable Tells Ant to locate the executable in the project’s base directory or the directory specified by dir. The default is false (use the user’s current path).
resultproperty The property where Ant will store the return code of this command. You can use this attribute only if failonerror is false (you’ll find details about this after the table). The default is blank.
searchpath Tells Ant to use the system PATH environment variable to find the command. The default is false.
spawn Tells Ant to start a process that will live after the Ant process has finished. You can’t use error, input, output, or result. The default is false.
timeout The time in milliseconds that Ant should wait before stopping this command. The default is null.
vmlauncher Tells Ant whether to use the JVM’s execution functionality instead of the operating system’s shell. The default is true.
Tagged : / / / / / / / / /