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.

Sunday, July 06, 2014

Operating Systems

As most people know, Windows XP and Office 2003, both produced by Microsoft, both used by many people around the world, are no longer supported. This means bugs won't be fixed, support for new types of hardware won't be provided and security problems will go unaddressed. There are a number of options here. One is to buy a new/replacement PC with a new license of Microsoft Office.  Another is to continue using your old hardware and get either Ubuntu or lubuntu Linux installed on your computer, along with a copy of LibreOffice to replace Microsoft Office. Ubuntu Linux and lubuntu Linux are free - all you need is someone to install them. Ubuntu requires better hardware and is more avant garde. lubuntu runs on very modest systems and is more familiar looking for people used to running Windows XP.

I was helping a friend with her Windows 8 laptop. I had a look at it and tried to help but had to return it to her to take to a Windows 8 specialist to fix things and upgrade to Windows 8.1.

Not many people are aware of a problem with people using old Ubuntu Linux systems. This only applies to people running Ubuntu Linux on computers with less than 700MB of RAM (memory). Earlier versions of Ubuntu Linux ran fine on PCs with 512MB of RAM. However, if your PC has less than 700MB of RAM, Ubuntu will try to struggle through and still work. The result has been described as slow and occasionally prone to crashing. My solution to this is to install lubuntu Linux (essential Ubuntu Light) on said systems as it requires 128MB of RAM. Personally I'd go for systems with at least 256MB RAM.

Contact has leaflets about 1) free software and 2) lubuntu.

Monday, April 21, 2014

Paula's cat, Alice, had to be put down. Rest in peace. She is survived by Geraldine.

Wednesday, March 05, 2014

Cooking

For the first time in over a decade I've cooked some stir-fry. It was lovely :)

Thursday, February 27, 2014

Linux Voice

A new Linux magazine has arrived - Linux Voice. Looks very interesting. They are going to re-license their content within 9 months of it being published.

Very nice :)

Sunday, December 22, 2013

Been to a Christmas Carol service, thinking of you Dad.

Saturday, November 23, 2013

Money saving tip - memory cards etc

I was recently given some memory sticks by a friend (EH) for fixing her laptop (thankyou, EH). So I started looking on Amazon UK for dedicated USB memory stick pouches but all the suitable pouches were £16+. So I had a think. And I remembered I had some spare transparent pencil cases (which I previously used to hold unit cards when I was playing the Babylon 5 : A Call to Arms wargame).

It turns out the cases are cheap and better (you can see what's inside without having to open the case).

Monday, November 18, 2013

To coin a phrase - abandonment anxiety...

... is what people with mental health problems often have regarding their care in the community.

Monday, November 11, 2013

Miniatures

For the first time in years I have started to paint miniatures for RPGs. This time it is the Judge Dredd figures by Mongoose Publishing.

Sunday, November 10, 2013

Relaxation

Have taken this weekend off from doing C++ stuff.

Yesterday was all 3 Jurassic Park films.

Been listening to BBC Radio 1's Live Lounge 2013 today.

Luxury :)

Thursday, October 24, 2013

When I was a teenage coder, for English Literature I was told to read the classics... so I spent 5 weeks worth of pocket money on "The C Programming Language" by K&R.

Experience is a harsh mistress

This month's lesson is...

Act in haste, repent at leisure.

Monday, October 21, 2013

Reality Poisoning.

Since I was a teenager. I suffered from Reality Poisoning which I escaped by playing Dungeons & Dragons (and, later on, Mongoose Traveller).

I was having a Reality Poisoning spell over the weekend when I realised it was similar to what other people call Depression.

Thursday, October 03, 2013

Neurocomic by Dr M. Farinella and Dr H. Ros

This is a graphic novel about the mind and the brain. It's something that I've been studying on Wikipedia for some time.

It's brief and easy to read. It may take concerted effort to remember the key parts - however, I think the effort involved is worth it.

Sunday, September 29, 2013

Cinema and Mental Health

I went to see Blue Jasmine recently. It was a good film with a real life kind of ending. Cate Blanchett was excellent as Jasmine. We get to see the side effects of a mental health problem but it's not mentioned in the film's dialogue - but Jasmine does take a lot of pills.