Hello All,

I have shell script which runs on unix box but recently we moved to windows box.
I am completely zero in VB script I need you guys help to convert the below script to VB
Thanks in advance for the help.

CheckQDepth()
{
 arch_log_file=`ls $arch_dir |grep $FNPARAM | tail -2 |head -1`
 x=1
 export flag=0
 flag1=0
 if [[ ${arch_log_file} != "" ]] ; then
 grep ^"<tr>" $arch_dir/$arch_log_file >$tmp_arch_file
 while [ $x -le 9 ]
 do
   QueueLine=`awk '{ print FNR ":" $0 }' $tmp_file | grep ^"$x:"`
   QueuearchLine=`awk '{ print FNR ":" $0 }' $tmp_arch_file | grep ^"$x:"`
   QueuearchDepth=`echo $QueuearchLine | awk -F'<[^<>]+>' '{ print $15 }'`
   QueueDepth=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $15 }'`
   if [ $QueueDepth -gt $Qdepth_Threshold ] ; then
     if [ $QueuearchDepth -gt $Qdepth_Threshold ] ; then
       if [ $QueueDepth -gt $QueuearchDepth ] ; then
          if [ $flag -eq 0 ] ; then
          echo "Begin QueueWatcher Check at `date` "
          flag=1
          fi
          if [ $flag1 -eq 0 ] ; then
          echo " "
          echo "Checking the Queue Depths of all Queues"
          echo " "
          flag1=1
          fi  
          echo "Queue $x has a depth of $QueueDepth which has crossed the threshold limit"
       fi
     fi
   fi
   x=$(( $x + 1 ))
 done
 rm -f $tmp_arch_file
 else
 while [ $x -le 10 ]
 do
   QueueLine=`awk '{ print FNR ":" $0 }' $tmp_file | grep ^"$x:"`
   QueueDepth=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $15 }'`
   if [ $QueueDepth -gt $Qdepth_Threshold ] ; then
      if [ $flag -eq 0 ] ; then
          echo "Begin QueueWatcher Check at `date` "
          flag=1
      fi
   echo "Queue $x has a depth of $QueueDepth which has crossed the threshold limit"
   fi
   x=$(( $x + 1 ))
 done
 fi
}

CheckStepID()
{
 x=10
 flag2=0
 LineTotal=`awk 'END { print NR }' $tmp_file`
 while [ $x -le $LineTotal ]
  do
  QueueLine=`awk '{ print FNR ":" $0 }' $tmp_file | grep ^"$x:"`
  StepID=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $9 }'`
  if [ $StepID -gt $Stepid_Threshold ] ; then
  BPID=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $7 }'`
  BPNAME=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $17 }'`
  grep -q "$BPID" $BPIgnoreList ; ret=$?
  echo $BPNAME | grep -vq "RSI" ; ret1=$?
  if [ $ret1 -ne 0 ] ; then
   if [ $ret -ne 0 ] ; then
      if [ $flag -eq 0 ] ; then
          echo "Begin QueueWatcher Check at `date` "
          flag=1
      fi
      if [ $flag2 -eq 0 ] ; then
       echo " "
       echo "Chechking the Step IDs Of active BPs"
       echo " "
       flag2=1
      fi
     echo "The BP $BPNAME with the ID $BPID has a Step ID of $StepID which has crossed the threshold limit"
   fi
  fi
  fi
  x=$(( $x + 1 ))
  done
}

CheckMSec()
{
 x=10
 flag3=0
 LineTotal=`awk 'END { print NR }' $tmp_file`
 while [ $x -le $LineTotal ]
  do
   QueueLine=`awk '{ print FNR ":" $0 }' $tmp_file | grep ^"$x:"`
   Msec=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $15 }'`
   MsectoMin=$(($Msec/$((60*1000))))
   if [ $MsectoMin -gt $Msec_Threshold ] ; then
   BPID=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $7 }'`
   BPNAME=`echo $QueueLine | awk -F'<[^<>]+>' '{ print $17 }'`
   grep -q $BPID $BPIgnoreList ; ret3=$?
   echo $BPNAME | grep -vq "RSI" ; ret4=$?
     if [ $ret4 -ne 0 ] ; then
       if [ $ret3 -ne 0 ] ; then
         if [ $flag -eq 0 ] ; then
          echo "Begin QueueWatcher Check at `date` "
          flag=1
         fi
         if [ $flag3 -eq 0 ] ; then
           echo " "
           echo "Checking for long running BPs"
           echo " "
           flag3=1
         fi
      echo "The BP $BPNAME with the ID $BPID has been running for $MsectoMin minutes which has crossed the threshold limit"
     fi
     fi
   fi
   x=$(( $x + 1 ))
  done

}

### DECLARATIONS   #######
##set -x
export Qdepth_Threshold=$2
export Msec_Threshold=$4
export Stepid_Threshold=$3
BP_ID=$1
FNPARAM=$5
ScriptName=Queuewatcher_Check
tmp_dir=/u00/edisprod/working_storage/$ScriptName.$BP_ID
export tmp_file=$tmp_dir/Temp_Queuelog
export tmp_arch_file=$tmp_dir/Temp_arch_Queuelog
arch_dir=/documents/logs/Qwatcher/archive/
log_file=`ls $arch_dir |grep $FNPARAM | tail -1`
export BPIgnoreList=/u00/edisprod/ftpini/Queuewatcher_Check_BPIgnoreList.cfg
mkdir ${tmp_dir}
cd ${tmp_dir}
grep ^"<tr>" $arch_dir/$log_file >$tmp_file

CheckQDepth
CheckStepID
CheckMSec
rm -f $tmp_file
rmdir $tmp_dir 
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.