Thursday, July 30, 2015

Getting in touch

I don't know how to edit the top of this blog.

For the moment, if you need to contact me, don't e-mail schizopanic@hotmail.com, please email IanBruntlett@hotmail.com

Saturday, January 24, 2015

A bit more code

And here is the brains behind my stufftar backup (Bash) script...

# perform_backup
# $1 - stub of .tar.gz filename
# $2 - name of log file e.g. "scripts/stufftarlog.txt"
# $3 - directory to do the tarring in
# $4 onwards - files/directories to put in .tar.gz file relative to $3
function perform_backup()
{
  if [ $# -lt 4  ]
  then
    echo "Error perform_backup() insufficient no of parameters";
    return 1;
  fi;

 FILENAME_STUB=$1
 DESTINATION_FILENAME=$1`date "+_%d_%B_%Y.tar.gz"`
 LOGFILE=$2
 TAR_DIR=$3
  if [ $STUFFTAR_VERBOSE -gt 0 ]
  then
    echo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}
    echo DESTINATION_FILENAME=$DESTINATION_FILENAME e.g. Desktop_28_December_2014.tar.gz
    echo FILENAME_STUB=$FILENAME_STUB
    echo LOGFILE=$LOGFILE
    echo TAR_DIR=$TAR_DIR
  fi
  CURRENT_TIME=`date "+%H:%M:%S"`
  cd $TAR_DIR
  echo_and_log $LOGFILE $CURRENT_TIME Backing up key $TAR_DIR $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}files to $DESTINATION_FILENAME

  /usr/bin/time -f "%E mins:secs " tar -czf $DESTINATION_FILENAME $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} ${14} ${15} ${16} ${17} ${18} ${19} ${20}
  exit_if_failed $? "perform_backup to " $DESTINATION_FILENAME
  echo File count:-
  tar -tvf $DESTINATION_FILENAME | wc -l
  ls -lh $DESTINATION_FILENAME
  echo
  cd;
  return 0;
}

Wednesday, November 12, 2014

A friend asked me today: what is your star sign? After a moment of thought, I replied: "a radio telescope".

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

Sunday, August 03, 2014

Improved script file "synclamp"

Initially synclamp (described elsewhere) tried to create its destination directory if it did not exist. I decided to check for its existence and exit synclamp with an error message.

Here is the old code:-
echo Ensuring destination directory $FILES_STICK exists
mkdir -p $FILES_STICK

Here is the updated code:
# August 2014. If memory stick not found then exit with error message
 if [ ! -d $FILES_STICK ] ; then
    echo "Please insert missing memory stick $FILES_STICK";
    exit 1;
fi;

Friday, July 25, 2014

Done a little bit of (shell) programming

Here it is...

#!/bin/bash
# Script file to synchronise LAMP files. Ian Bruntlett July 2014
FILES_LAMP=/var/www/html
FILES_STICK=/media/$LOGNAME/DARWIN/lamp/html
FILES_CP_OPTS="-irvua"
echo Running $0
ls -lh $0
echo Ensuring destination directory $FILES_STICK exists
mkdir -p $FILES_STICK
echo Copy files from live LAMP directory to memory stick
cp $FILES_CP_OPTS $FILES_LAMP/* --target-directory=$FILES_STICK
echo Copy files from memory stick to hard disc
cp $FILES_CP_OPTS $FILES_STICK/* --target-directory=$FILES_LAMP
echo $0 done

Monday, July 07, 2014

Business as usual

Had a routine blood test today - just one bottle.

Am trying to lose weight. I might not be eating properly because if I skip breakfast (porridge, skimmed milk and honey) I get dizzy spells. So instead of eating sandwich, salad and toast all the time, I'll also be eating other things - tinned food - that can go in the microwave.