itadmin shell script issue

Hi All,

I am facing issue when executing itadmin process list -a | grep XYX from a shell script .

The below script snippet is returning blank value " " even when the service is up and running.

PROCESS=`itadmin process list -a | grep XYZ`
if [ "${PROCESS}" == "" ]
then
echolog "Service is down"
exit 1
fi

But when I run the same command directly from windows command line I get the expected return value ie XYZ

itadmin process list -a | grep XYZ

 XYZ.

Not sure why it is failing when called from shell script. 

Thanks in advance.

  • This is on 64-bit windows machine provided with a unix like environment for scripting.

  • In reply to Jackson11:

    grep isn't installed by default on Windows by default. Are you running in Cygwin or something like that? Are you sure this question relates to Orbix though? For example if you replaced 'itadmin process list -a' with 'echo XYZ' would you see the same results?

    Also, it's worth noting that itadmin is a TCL parser, so you could achieve the same results in TCL. Here is a simple TCL script that would do this, you can copy this and save it as simple.tcl

    if {$argc > 0} {

    set active [process list -a]

    if [regexp -- $argv $active] {

    puts stdout "$argv running"

    } else {

    puts stdout "$argv not running"

    }

    } else {

    puts stderr "This is a simple application to check if a process is running"

    puts stderr "Usage:"

    puts stderr "itadmin simple.tcl <process name>"

    }

    If I run this in an environment where I have the naming service running here is the output:

    itadmin simple.tcl

    This is a simple application to check if a process is running

    Usage:

    itadmin simple.tcl <process name>

    itadmin process list -a

    iona_services.naming.DUB-JURISL

    itadmin simple.tcl naming

    naming running

    itadmin simple.tcl XYZ

    XYZ not running

  • In reply to MartinMu:

    Hi Martin,

    Thanks a lot for the quick response. Yes I am using a software package like cygwin  that provides a Unix-like environment for scripting. And grep commands works totally fine as I am able to get the running service when I directly execute "itadmin process list -a | grep XYZ" .

    The shell script was working fine for few months and suddenly it stopped working. To resolve this problem  I am calling a perl script (test.pl) from shell : and test.pl calls itadmin process list -a internally.

    PROCESS=`D:/software/perl-5.8.4/bin/perl.exe test.pl | grep XYZ`

    echo "PROCESS : $PROCESS" returns PROCESS : XYZ

    Is there a possibility that it may be linked to server node cluster configuration?

    I still don't understand when itadmin process list -a | grep XYZ works fine when executed directly from command line and fails when executed from shell script.

    In the mean time I will modify the shell do call tcl script and see if it is able to catch the correct running service.

    Many thanks

    Jackson

  • In reply to Jackson11:

    Hi,

    I debugged the shell script using set -x and

    PROCESS=`itadmin process list -a | grep XYZ` is working fine when I give the full path for itadmin exe ie

    PROCESS= `FULLPATH\itadmin.exe process list -a | grep XYZ` > This has resolved the problem.

    Just before this script stopped working we switched between 2 server nodes not sure if this has caused this problem.