#!/bin/ksh # # Fun wrapper to psql for xmlterm. # Try running: # xmlpg "select * from tablename" # xmlpg "select now()" # # For Max fun, run using xmlterm ;) # # Greetings: # Thomas O'Dowd # if [[ $# -ne 1 ]] ; then print -u2 "Usage: xmlpg 'sql command'" print -u2 "Set PGDATABASE, PGHOST, PGPORT and PGUSER as required." exit 1 fi print "\0033{S${LTERM_COOKIE}" # Start HTML stream print "SQL:$1
" psql -H -c "$1" print "\0000"; # Terminate HTML stream