Being on digest my example is probably late. At any rate, as an example here is something I use for automated DB reports via email. Breaking down the process into the SQL-commands(.sql file) the shell script (below) , and the cron process allows me to modify and test each component, or parameter within a component w/o affecting the rest. The CAP sequences, like 'XXXXX' of course, are just blanks. Any critique is welcome ....................... Horst.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #!/bin/bash # report members that came through specific door during the last N days. # files/processes involved: # crontab(root) m h * * * /root/cron/bin/door9-rpt.sh # $sql-cmds, $sql-rpt - see below # things to customize: sql_target='-h localhost -u UUUUU -pXXXXXX' sql_cmds='/root/cron/bin/door9-rpt.sql' sql_rpt='/root/cron/log/door9-rpt.txt' send_to=' [EMAIL PROTECTED],[EMAIL PROTECTED] ' send_cc=' -c [EMAIL PROTECTED] ' ##send_bcc=' -b user@domain ' # find members according sql_cmds : mysql $sql_target < $sql_cmds > $sql_rpt # Here we would edit the report # send_<to|cc|bcc> __see-above__ cat $sql_rpt | mail $send_to $send_cc $send_bcc -s "SSSSSSSS; $(date)" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On Wed, 13 Mar 2002, Bob Crandell wrote: > mysql -u root -p > mysql> create database phpgroupware ; > mysql> grant all on phpgroupware.* to phpgroupware@localhost identified by > 'password'; > mysql> quit > > These are the lines to create a database and set a password. How would I put this > in a shell script? I want it to run unattended, at least, almost unattended. > > Thanks > -- > Bob Crandell > Assured Computing > When you need to be sure. > Cell 541-914-3985 > FAX 240-371-7237 > [EMAIL PROTECTED] > www.assuredcomp.com > >
