OSQL batch scripting

We have an issue on a Windows 2003 SP2 server with Symantec BackupExec 11d (with the latest hotfixes installed), with an Sony AIT4 StorStation Library where we get a cleaning tape error on a couple of the backup jobs - but the jobs themselves complete with no issue - except that the error "cleaning media was mounted" is logged - except these slots are not marked as cleaning slots - and the tapes are either brand new or a long erase has been run previously.

We have a single cleaning tape in slot 8 - and when the drive requests a cleaning request - it uses the tape because it is marked as a cleaning slot.

From the Veritas/Symantec knowledgebase - we know that this is a bug that will be fixed in the next major release - but for the time being know that these commands fix the issue.

osql -E -S sgs-sr-backup\bkupexec -d bedb
delete from jobhistorydetail where finalerrordescription like '%library%'
go

We are looking to script this to run automatically at regular intervals - but the first command has to be run - then the lines after piped into the osql prompt.

Does anyone have an idea how to do this? All suggestions gratefully received.

How
LVL 32
and235100Asked:
Who is Participating?
 
SteveGTRConnect With a Mentor Commented:
You could do this:

@echo off

(echo delete from jobhistorydetail where finalerrordescription like '^%library^%')>_temp.txt
(echo go)>>_temp.txt
(echo exit)>>_temp.txt

osql -E -S sgs-sr-backup\bkupexec -d bedb - i _temp.txt

del _temp.txt

0
 
and235100Author Commented:
Yes, possibly - I can see what that is attempting to do - but will it work? As far as I know - the "osql> " prompt will not take a text file...

I will try this now - and get back to you...
0
 
SteveGTRConnect With a Mentor Commented:
It will do it if I post the correct syntax. I've got an extra space on the command line :(

osql -E -S sgs-sr-backup\bkupexec -d bedb -i _temp.txt
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
and235100Author Commented:
I have just tried what you suggested - all that comes up is the list of supported commands for osql.

Any other ideas?
0
 
and235100Author Commented:
I will try the ammendment...
0
 
and235100Author Commented:
Excellent - works a treat!!!

Thank you - nice easy one for you...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.