Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I print the most current version of a database error log?

Status
Not open for further replies.
Aug 1, 2002
1
US
Tek-Tips rocks! I am new to this resource and have read many posts and I am very impressed of the support and knowledge of the members here. Maybe someone could give me a little guidance here. I am looking for a way to print the most current version of an error log based on a database name that a script will prompt me with using the c shell. The output of the directory looks like this:

Jul 24 22:30 master.07-24-02-223040
Jul 25 22:30 master.07-25-02-223039
Jul 26 22:30 master.07-26-02-223040
Jul 27 22:30 master.07-27-02-223042
Jul 28 22:30 master.07-28-02-223040
Jul 29 22:30 master.07-29-02-223041
Jul 30 22:30 master.07-30-02-223042
Jul 31 22:30 master.07-31-02-223041
Jul 24 22:31 ntcss_org.07-24-02-223110
Jul 25 22:31 ntcss_org.07-25-02-223109
Jul 26 22:31 ntcss_org.07-26-02-223110
Jul 27 22:31 ntcss_org.07-27-02-223111
Jul 28 22:31 ntcss_org.07-28-02-223110
Jul 29 22:31 ntcss_org.07-29-02-223111
Jul 30 22:31 ntcss_org.07-30-02-223112
Jul 31 22:31 ntcss_org.07-31-02-223111
Jul 24 22:52 supply.07-24-02-225227
Jul 25 22:52 supply.07-25-02-225222
Jul 26 22:52 supply.07-26-02-225235
Jul 27 22:53 supply.07-27-02-225303
Jul 28 22:52 supply.07-28-02-225237
Jul 29 22:53 supply.07-29-02-225313
Jul 30 22:53 supply.07-30-02-225309
Jul 31 22:52 supply.07-31-02-225253
Jul 24 22:52 sybsystemprocs.07-24-02-225253
Jul 25 22:52 sybsystemprocs.07-25-02-225247
Jul 26 22:53 sybsystemprocs.07-26-02-225300
Jul 27 22:53 sybsystemprocs.07-27-02-225329
Jul 28 22:53 sybsystemprocs.07-28-02-225302
Jul 29 22:53 sybsystemprocs.07-29-02-225338
Jul 30 22:53 sybsystemprocs.07-30-02-225335
Jul 31 22:53 sybsystemprocs.07-31-02-225318

How can a script do the following:
1. Show the list of databases to choose from (master,ntcss_org,supply or sybsystemprocs)
2. Given the choice automatically print out the most recent database error log


 
Use a case statement for the first question since you already know the database names.

Then for the second question, based upon your case statement, use this variable: DATE=`date +%m-%d-%y`

grep ${CASE_STATEMENT_VAR}.${DATE} ${DIR - where DIR == the directory they are in}

read RESP?"Would you like to print this (Y/N)? "
if [[ ${RESP} == [Yy]* ]]
then
lp -d ${PRINTER_CHOICE} ${FILE}
fi


Something to that effect for a quick script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top