List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 19 1999 7:11am
Subject:Re: SPOOL command in mysql
View as plain text  
On Sun, 1999-09-19 08:48:47 +0200, Leif Neland wrote:
> On Sat, 18 Sep 1999, Tõnu Samuel wrote:
> > There is utility in most unixes called "tee" which can redirect
> > output to some place and at once output it to stdout. Using it
> > prorably can be done this "dual output" for file and printer.
[...]
> It would be nice to be able turn on spool (save output to file) at
> will, instead of remembering to turn on a hack at entry to mysql.

I really wouldn't call using tee a hack, that's quite a normal and
frequently used Unix command, but ...

Just quit 'mysql' and have a look at ~/.mysql_history, when your query
finally runs successfully.  This file stores all your input lines.

You could even use a small shell script to select the last queries for
printing, see attachment.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7

#!/usr/local/bin/bash

HISTFILE=~/.mysql_history

OIFS="$IFS"; IFS=';'
set -- `tail -20 $HISTFILE`
IFS="$OIFS"
shift

PS3='Please, select number of SQL statement: #'
select query in "$@"
do
  if [ -n "$query" ]; then break; fi
done

echo -e "\nPrint: $query"

Thread
SPOOL command in mysql(Alex)17 Sep
  • Re: SPOOL command in mysqlMartin Ramsch17 Sep
    • Re: SPOOL command in mysqlJames Manning17 Sep
  • Re: SPOOL command in mysqltonu18 Sep
    • Re: SPOOL command in mysqlLeif Neland19 Sep
      • Re: SPOOL command in mysqlMartin Ramsch19 Sep
      • Re: SPOOL command in mysqlEd Carp19 Sep
      • Re: SPOOL command in mysql(Alex)19 Sep
      • Re: SPOOL command in mysqlTonu Samuel20 Sep