return to first page linux journal archive
keywordscontents

Listing 1. Shell Code example

#!/bin/sh
# Vars declaration
CUS_CODE="ACM005";
CUS_NAME="Donald Duck";
CUS_PHONE="1-555-DUCK-FREE";
CUS_EMAIL="duck\@disneyland.fl.us";

# Trying lock the table
if nosql lock customer.rdb
then
    # "Echo -e" expands chars such as \n and \t needed for NoSQL
formatting
    echo -e \
    "\nCODE\t${CUS_CODE}\nNAME\t${CUS_NAME}\nPHONE\t   \
    ${CUST_PHONE}\nEMAIL\t${CUS_EMAIL}\n" |\
nosql listtotable | nosql merge CODE NAME PHONE EMAIL customer.rdb |\
    nosql write -s customer.rdb
    # Final unlocking
    nosql unlock customer.rdb
else
   # If couldn't lock customer.rdb
   echo "$0: warning, couldn't lock table."
fi