Page 1 of 1 1
Topic Options
#132999 - 2005-01-26 04:40 PM dealing with quotes, dbl quotes and SHELL
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
I'm having some problems figuring out the syntax for this SHELL command line. I want it to launch osql on the machine and run the SQL command. Here's my latest try, which isn't working:

Code:
 
$SQLPath = 'c:\Program Files\Microsoft SQL Server\80\Tools\Binn\'
$ShellCmd = $SQLPath + Chr(34) + osql.exe -E -Q BACKUP DATABASE [TestRepository] TO [TestRepository_Backup] WITH INIT , NOUNLOAD , NAME = N'TestRepository_Backup', NOSKIP , STATS = 10, NOFORMAT + Chr(34)



Thanks for any help with this!

Top
#133000 - 2005-01-26 04:45 PM Re: dealing with quotes, dbl quotes and SHELL
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
have you got it to work from a command prompt? if not, do that first and then incorporate that into the shell command in your script. If you have got it to work successfully from the command line, post the working command.
_________________________
Eric

Top
#133001 - 2005-01-26 04:58 PM Re: dealing with quotes, dbl quotes and SHELL
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Thanks. Yep, it works from the command line like this:

Code:
 
osql -E -Q "BACKUP DATABASE [TestRepository] TO [TestRepository_Backup] WITH INIT , NOUNLOAD , NAME = N'TestRepository_Backup', NOSKIP , STATS = 10, NOFORMAT"



On another attempt within KiXtart, I tried:

Code:
 
$ShellCmd = $SQLPath + osql.exe -E -Q + Chr(34) + BACKUP DATABASE [TestRepository] TO [TestRepository_Backup] WITH INIT , NOUNLOAD , NAME = N'TestRepository_Backup', NOSKIP , STATS = 10, NOFORMAT + Chr(34)



...thinking that all I'd need to do is replace the dbl quotes with the Chr(34) where they appear in the simple command-line version. This still reports an error in Line 62 (where this code is placed).

Top
#133002 - 2005-01-26 05:00 PM Re: dealing with quotes, dbl quotes and SHELL
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You've got yourself in a bit of a mess there.

I think this is what you want:
Code:
$=SetOption("WrapAtEOL","ON")
$SQLPath = 'c:\Program Files\Microsoft SQL Server\80\Tools\Binn\'
$ShellCmd = '"'
+ $SQLPath
+ 'osql.exe" -E -Q "BACKUP DATABASE [TestRepository] TO [TestRepository_Backup] WITH INIT , NOUNLOAD , NAME = N'
+ "'TestRepository_Backup'"
+ ', NOSKIP , STATS = 10, NOFORMAT"'
"COMMAND TO EXECUTE:" ? $ShellCmd ?



Are you sure about the two "n"s in "..\Binn" ?

Top
#133003 - 2005-01-26 05:04 PM Re: dealing with quotes, dbl quotes and SHELL
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
couple more questions since i can't really test it here. First, what is the error that your are getting?

And second, do you know if this has to be run from a command prompt or could you go to start->run and run it from there as well?
_________________________
Eric

Top
#133004 - 2005-01-26 05:22 PM Re: dealing with quotes, dbl quotes and SHELL
tr6boy Offline
Starting to like KiXtart

Registered: 2001-10-24
Posts: 131
Thanks, I'll try it. Yep, 2 'n' in BINN. Weird MS stuff. Never been sure why they did that, but it's been that way in SQL Server as long as I remember...
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 611 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.077 seconds in which 0.055 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org