Welcome, Guest. Please Login or Register
AIX User Group Forum
Sep 6th, 2010, 1:50am
News: Welcome to the AIX User Group forum.
Home Help Search Login Register


Pages: 1
Send Topic Print
Script with no output, what is wrong on this cript (Read 14 times)
vinayrao
Freshman
*


AIX User Group
Rocks!

Posts: 1
Script with no output, what is wrong on this cript
Jan 18th, 2010, 3:48pm
 
#!/bin/sh

# # # are we in debug mode?
if [ $# -ge 1 -a "x$1" = "x--debug" ] ; then
       DEBUG=1
       TEE_DEST=`dirname $0`/debug--`basename $0`--`date | sed 's/ /_/g;s/:/-/g'`
else
       DEBUG=0
       TEE_DEST=/dev/null
fi

# # # what OS is this?
KERNEL=`uname -s`

# # # assert we are in a supported OS
case "x$KERNEL" in
       "xLinux") ;;
       "xSunOS") ;;
       "xDarwin") ;;
       "xFreeBSD") ;;
       *)
               echo "UNIX flavor [$KERNEL] unsupported for Splunk *NIX App, quitting" > $TEE_DEST
               exit 1
               ;;
esac

# # # check for presence of required commands; we do not assume that which(1) exists, and roll our own
queryHaveCommand () # returns 0 if found, 1 if not
{
       [ "x$1" = "xeval" ] && shift
       for directory in `echo $PATH | sed 's/:/ /g'`
       do
               [ -x $directory/$1 ] && return 0
       done
       return 1
}

failLackCommand ()
{
       echo "Not found command [$1] on this host, quitting" > $TEE_DEST
       exit 1
}

failLackMultipleCommands ()
{
       echo "Not found any of commands [$*] on this host, quitting" > $TEE_DEST
       exit 1
}

assertHaveCommand ()
{
       queryHaveCommand $1
       if [ $? -eq 1 ] ; then
               failLackCommand $1
       fi
}

assertHaveCommandGivenPath ()
{
       [ "x$1" = "xeval" ] && shift
       [ -x $1 ] && return
       echo "Not found commandGivenPath [$1] on this host, quitting" > $TEE_DEST
       exit 1
}

failUnsupportedScript ()
{
       echo "UNIX flavor [$KERNEL] unsupported for this script, quitting" > $TEE_DEST
       exit 0
}

# # # eschew the antedeluvial awk
if [ "x$KERNEL" = "xSunOS" ] ; then
       AWK=nawk
else
       AWK=awk
fi

# # # check for presence of a few basic commands ubiquitous in our scripts
assertHaveCommand $AWK
assertHaveCommand egrep

# # # normalize environment
if [ "x$KERNEL" = "xSunOS" ] ; then
       unset LD_PRELOAD
fi

# # # enable check for OS versions, if needed later
if [ "x$KERNEL" = "xSunOS" -a `uname -r` = "5.8" ] ; then
       SOLARIS_8=true
else
       SOLARIS_8=false
fi
if [ "x$KERNEL" = "xSunOS" -a `uname -r` = "5.9" ] ; then
       SOLARIS_9=true
else
       SOLARIS_9=false
fi

Back to top
 
 
  IP Logged
Tim
Freshman
*


AIX User Group
Rocks!

Posts: 16
Re: Script with no output, what is wrong on this c
Reply #1 - Feb 22nd, 2010, 6:26am
 
nothing is wrong with the script. but it's not aware of AIX :

case "x$KERNEL" in
      "xLinux") ;;
      "xSunOS") ;;
      "xDarwin") ;;
      "xFreeBSD") ;;
      *)

Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print