#!/bin/bash

# ------------------------------------------------------------
# RPC Project :
# RPC_list : return the list of all available RPC commands
# works without argument
# P. Robert, LPP, 2011-03-30
# ------------------------------------------------------------
Narg=0

if( (test $# = 1 ) && (test $1 = -h ) ) ; then hh=1 ; else hh=0 ; fi

if test $# != $Narg || test $hh = 1
   then
   echo "$appli :  create list of all available RPC commands"
   echo "$appli    require $Narg argument(s), ex:"
   if test $hh = 1 ; then exit 0 ; fi
   echo "$appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi
echo " -------------------------------------------------------------------"
echo " create list of all available RPC commands"
echo " -------------------------------------------------------------------"

if test -f toto1.tmp ; then \rm toto1.tmp ; fi
if test -f toto2.tmp ; then \rm toto2.tmp ; fi
if test -f RPC_list.txt ; then \rm RPC_list.txt ; fi

ls -1 $RPC_DIR/bash/RPC_* | sed /~/d  > toto1.tmp
sed "s/^/basename /" toto1.tmp > toto2.tmp
sh toto2.tmp > RPC_list.txt

\rm toto1.tmp toto2.tmp

echo
echo "Content of RPC_list.txt :"
echo "-------------------------"
echo
cat RPC_list.txt
nbcom=`wc -l RPC_list.txt | cut -f1 -d " " `
echo 
echo "Nb of RPC commands : $nbcom"
echo
echo " -------------------------------------------------------------------"

