Tuesday, November 11, 2014

Done my first function in bash.

Been doing a lot of Linux system's administration studies recently. Finished reading "Linux Pocket Guide (2e)" from cover to cover for the first time ever.

Am returning to "Learning PHP, MySQL, JavaScript, CSS & HTML5".

In the meantime, here is a function newly written for my stufftar backup shell script...

function echo_and_log()
{
  if [ $STUFFTAR_VERBOSE -gt 0 ]
  then
    echo echo_and_log : parameter count $#, logfile $1, text $2 $3 $4 $5 $6 $7 $8 $9
  fi
  if [ $# -lt 2  ]
  then
    echo "Error echo_and_log insufficient no of parameters";
    return 1;
  fi;
  if [ ! -f $1 ]
  then
    echo WARNING $1 does not exist. Creating it now.
    touch $1
  fi;

  echo  `hostname` $2 $3 $4 $5 $6 $7 $8 $9
  echo  `hostname` $2 $3 $4 $5 $6 $7 $8 $9 >> $1

} # end function echo_and_log

No comments: