Shell Scripting question

Dave Tiger dave at tigeri.com
Thu Apr 15 10:55:08 BST 2004


Thanks Rodger for the info. Perl DBI is not an option at the moment but I
might go down that road if need be.

Sorry to be a bore but where in the string do I put the required -u -h -p
parts for the MySql connection ?

Once again thank you for the help.

Dave C

-----Original Message-----
From: Roger McCalman [mailto:roger at runcircle.co.uk] 
Sent: 15 April 2004 09:59
To: Dave Tiger
Cc: freebsd-users at uk.freebsd.org
Subject: Re: Shell Scripting question


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

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004
 





More information about the Ukfreebsd mailing list