[lug] Shell Script

Jeremy J Hinegardner/Boulder/IBM jeremyhi at us.ibm.com
Fri Aug 25 10:56:15 MDT 2000


What it is doing is creating a standard input stream on the fly.

The
PROCESS <<TERM
....
TERM
form says take the text between the TERM immediately following the
input redirection symbol and the line in which the TERM resides by 
itself and make that the standard input stream of the
associated PROCESS.  I hope that's obscure enough for you :)

The $1 in the query statement itself will be replaced with the first 
command line argument to the shell script.  So if the shell script was 
entitled
mysql_dostuff, then typing

mysql_dostuff volleyball

would select the records from the member's table in the samp_db
in which the interest field holds the word 'volleyball'

probably more information than you wanted... 

As for a resource, check out Learning the Bash Shell (O'Reilly) or
Portable Shell Programming by Bruce Blinn.  I've found the 
Blinn book to be invaluable

enjoy,

-jeremy

--
==================================================
Jeremy Hinegardner             jeremyhi at us.ibm.com


I have searched all my books and the library for information on the

<<QUERY_INPUT
 ...
QUERY_INPUT

portion of the following script.  I would appreciate a pointer to where
I can find out about it and/or an explantion.

#! /bin/sh
if [ $# -ne 1 ]; then echo "please specify one keyword"; exit; fi

mysql -t samp_db <<QUERY_INPUT
SELECT last_name, first_name, email, interests FROM member
WHERE interests LIKE "%$1%"
ORDER BY last_name, first_name;
QUERY_INPUT

--
Regards,
Bob Collins
                         Mailto:bcollins at csd.net
                      http://www.csd.net/~bcollins

_______________________________________________
Web Page:  http://lug.boulder.co.us
Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug






More information about the LUG mailing list