Monday, December 27, 2010

cygrunsrv: install, list, delete windows services

cygrunsrv is a program available with cygwin ( Cygwin is an incredible collection of utilities that are commonly available on unix-like os's (like Linux) that you can install on a Windows platform. And cygrunsrv is a handy utility to install, list, and manage windows services. Just try googling "how to create a windows service" and see what you can find. If you like the answers you get there, read no further. However, if you want to get started right now without any extra tools or computer language, then install cygwin and start using cygrunsrv. Here are some examples. All examples assume that you are running from the cygwin bash shell:

get program help: cygrunsrv --help

list services created and managed by cygrunsrv: cygrunsrv.exe --list

remove service created by cygrunsrv: cygrunsrv.exe --remove <service name>

Query a service created by cygrunsrv: cygrunsrv.exe --query <service name>

name="PFERD in Development Configuration"
cygrunsrv.exe --install pferd_dev --chdir 'c:\pegasus\ruby\pferd' --user <user> --passwd <password> --disp "$name" --path 'c:\ruby\bin\ruby.exe' --args 'script\server' --desc "$name"

name="SOS in DEV Configuration"
cygrunsrv.exe --install sos_dev2 --chdir 'd:\inetpub\ftproot\sos\development' --user <user> --passwd <password> --disp "$name" --path 'd:\ruby\bin\ruby.exe' --args 'd:\pggis\ruby\datastage\lib\sos_listener.rb' --desc "SOS DEV Listener"

Thursday, December 23, 2010

Groovy for SUSE 11.3

I had never done anything with Groovy (a scripting language for Java programmers) before and getting it set up was not obvious at first. I did not find anything specifically for SUSE Linux, but here's what worked:

  1. A Java JDK and Apache Ant should already be installed, if not, use Yast to install them, but make sure you also install the following Ant components:
    • ant-antlr
    • ant-junit
    • ant-trax
  2. Download and unzip (
    • Alternative: use the following command to pull down the latest and greatest (beta) version of Groovy
    • svn co
  3. cd groovy-src-1.7.6 (or the directory created by the svn command above)
  4. ant install
  5. cd target/install
  6. mkdir /opt/groovy-1.7.6
  7. find |cpio -pdmv /opt/groovy-1.7.6
  8. Add: /opt/groovy-1.7.6/bin to PATH
  9. export GROOVY_HOME=/opt/groovy-1.7.6
At that point you should be able to create and run your first groovy program or you can run "groovyConsole." Here's an example of a shell script running groovy, example.groovy which contains the following lines:

#!/usr/bin/env groovy

def whoami = "example.groovy"

def message = 'hello'
println whoami + ": hash of \"" + message + "\" = \"" + message.hashCode() + "\""

If you make this file executable, like "chmod 777 example.groovy" then you can run it like "./example.groovy" or just run "groovy example.groovy"