Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - filofax


#!/bin/bash
# $Id: filofax,v 1.31 2018/06/26 15:05:46 fulford Exp $
# $Source: /src/admin/usr/local/etc/RCS/filofax,v $
# $Revision: 1.31 $
# Author C W Fulford.
# Copyright 2013 (c) C W Fulford. All rights reserved.
# For assistance contact fulford@fulford.net 0709 229 5385
###################################################################
cmd=`basename $0`
syntax="$cmd [-c <config>] [-d] [-f <data_file>] [-v] [-X]"
ver=`echo "$Id: filofax,v 1.31 2018/06/26 15:05:46 fulford Exp $"|awk '{print $3,$4,$5}'`
while [ $# -gt 0 ];do
	case $1 in
		-c) conf=$2;shift 2;;
		-d) set -x;debug=:;shift;;
		-f) file=$2;shift 2;;
		-V) echo $cmd $ver;exit;;
		-v) verbose=:;shift;;
		-X) xserver="false";shift;;
		-*) echo $syntax >&2;exit;;
		*)f=$1;shift;;	
	esac
done
#set defaults
conf=~/.filofax.cf
fg=white;bg=blue;title="Filofax"
file=~/filofax/main
user=`id -nu`
#xserver=${xserver:-":"}
[ -f $conf ]||conf=/usr/local/etc/filofax.cf
vi=/usr/bin/vim
[ $view ] && vi=/usr/bin/view

if [ ! -r $conf ];then
	echo "$cmd: config file not found, using defaults!">&2
else
	eval `gawk -F: -v u=$user '$1~u{print $2}' $conf`
fi
if [ "$DISPLAY" -a "$xserver" != "false" ];then
      	xterm  -bg $bg -fg $fg -T "$title" -geometry 80x24 \
		-fs 12 -e "$vi $file" &
else
	$vi $file
fi

######################################################################
# This program is free software: you can redistribute it and or      #
# modify it under the terms of the Lesser GNU General Public License #
# as published by the Free Software Foundation, either version 3 of  #
# the License, or (at your option) any later version.                #
#                                                                    #
# This program is distributed in the hope that it will be useful,    #
# but WITHOUT ANY WARRANTY; without even the implied warranty of     #    
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      #
# GNU General Public License for more details.                       #
#                                                                    # 
# A copy of the Lesser GNU General Public License and the GNU        #
# General Public License is available at                             #
# <http://www.gnu.org/licenses/>.                                    #
######################################################################

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.