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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

isql and batch file 2

Status
Not open for further replies.

mrmovie

Technical User
Oct 2, 2002
3,094
GB
Hello All,
Please excuse my ignorance.
a work chum dumps a log every day by typing some command line prompts. they would like to automate this.
they do the following

"isql -Usa -P"

this gives a 1> prompt

"dump tran master with no_log"

this gives a 2> prompt

"go"

how can we script this? is it possible to do from a batch file? or what would a .sql file look like to do this?
any help would be ace.
regards
von moyla
 
Try creating a batch file with

osql -S master -q "dump tran master with no_log" -Usa -P


replacing the sa and blank password with whatever you need.
 
is the sa the "master" in your example?? sorry
 
right i am being thick, the master is the database and the sa is the bit that looks like -Usa.
the password for sa is blank.
anyway i can run the command and i get a password prompt, after this i hit return and get

CT-Library error:
ct_connect():user api layer: internal client library error: hafailover: trying to connect to server
 
ok, i dont have osql available on my machine. is there anyway i can do it using isql? or do i need to get a copy of osql?
 
I think "isql" is a line editor or basically the DOS equivalent of Query Analyser.

You can try something like
ISQL -S <servername> -d <dbname> -U<login> -P<password> -i query.qry

replace each of the lowercase variables with your values


and inside your query.qry file you have
dump tran master with no_log
GO


Not sure how to script it once you open it.
osql is the command
 
If nothing from other posts will work for you, try to use redirection of input from file:
Create 'some.txt' file with values, that you need
as answer for prompts folowed by ENTER ( new line or CR+LF )

create bat file 'somefile.bat' with commands
isql -Usa -P
dump tran master with no_log
go


and run it with: somefile.bat << some.txt

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
thank you for your posts gents/ladies. i havent had a chance to try the new ideas yet but needless to say you have most kind with efforts/info.

cheers,
richie von moyla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top