Shell Scripting question
Roger McCalman
roger at runcircle.co.uk
Thu Apr 15 09:58:31 BST 2004
On Tue, Apr 13, 2004 at 04:26:36PM +0100, Dave Tiger wrote:
> Hi List,
>
> I have looked around for a possible example for a shell script (new to sh
> scripting) to connect to a mysql db, select some data then create vars from
> the result and send the vars to some script a friend made for me to automate
> a job for me.
>
> Now I am a very good php developer but never ventured under the hood and
> tackle sh so any help would be very much appreciated.
I use
#!/bin/sh
mysql --skip-column-names --batch -e 'select ...' database |
while read col1 col2 col3 ... ; do
echo "process ${col1} ..."
done
for simple mysql tasks and reports otherwise I use perl and DBI. You
may need to change IFS and/or the column delimeter if the column data
has spaces, tabs or newlines in.
Cheers, Roger
More information about the Ukfreebsd
mailing list