Web Hosting Talk







View Full Version : help with shell script


scsi
02-15-2002, 02:22 PM
hi there,
I need to run a script for every record returned from mysql -u xxx -1xxx -D testdb -e "SELECT IdCK, Preset FROM CKTbl WHERE IntOpen = 1 " -N -s

and the record fields are the arguments of the script i need to run... any idea?

thank you in advance

priyadi
02-15-2002, 04:27 PM
Originally posted by scsi
hi there,
I need to run a script for every record returned from mysql -u xxx -1xxx -D testdb -e "SELECT IdCK, Preset FROM CKTbl WHERE IntOpen = 1 " -N -s

and the record fields are the arguments of the script i need to run... any idea?

thank you in advance

Quick hack with Perl:


open(SQL, "mysql -u xxx -1xxx -D testdb blahblahblah |");
while(<SQL>) {
s/\t/ /g;
system("script $_");
}


You probably can achieve more by using DBI, but I don't have the manual with me right now.