#132999 - 2005-01-26 04:40 PM
dealing with quotes, dbl quotes and SHELL
|
tr6boy
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
|
|
|
|
#133001 - 2005-01-26 04:58 PM
Re: dealing with quotes, dbl quotes and SHELL
|
tr6boy
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
   
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 611 anonymous users online.
|
|
|