You are not logged in.

#1 2010-12-09 03:06:38

crouse
Arch Linux f@h Team Member
From: Iowa - USA
Registered: 2006-08-19
Posts: 907
Website

Simple sqlite+bash phonebook

Phone Book Script - Version 2
This version uses sqlite3 and bash.
Still has things i could fix i suppose ...but it works for what i wanted.

I wanted to play with sqlite and bash, so I decided to revamp my older bash phone book script.
And before you ask....... yes, I use this everyday tongue  I work from the command line all day long, and
for me simple is better, console is better than gui, and it did what I wanted it to... thought I'd share
it just in case someone else had this particular itch they needed to scratch.

Yes.. I know the code could be condensed, shortened ...whatever, but I prefer "quickly understandable"
vs "obfuscated" code myself.... so knock yerself out if you want too... but I'll leave that to you wink

#!/bin/bash
# Crouse's sqlite+bash phonebook application.
# 11-22-2010 Crouse

# Check if requirements are installed. 
clear
if [[ -z $( type -p sqlite3 ) ]]; then echo -e "REQUIRED: sqlite3 -- NOT INSTALLED !";exit ;fi

# Check if database already exists, if not, create it.
database="/home/$USER/.phonebook.db"
 if [ -e "$database" ];then
     echo ""
 else
     echo "Datase does not exist - Creating now"
sqlite3 $database "create table phonebook (id INTEGER PRIMARY KEY,First TEXT,Last TEXT,Street TEXT,City TEXT,State TEXT,Zip TEXT,Phone TEXT,Email TEXT, Notes);"
    echo "Database created at $database"
 fi

# Check options given to the program and "do stuff".
case ${1} in
 
# oops--you didn't give me anything
"") echo "Crouse's sqlite+bash phonebook"
    echo "================================"
    echo "Usage: ${0##*/} 
Crouse's sqlite+bash phonebook
================================
Usage: pb 

Offline

Board footer

Powered by FluxBB