Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 xp_cmdshell in SQL2005 issue

Author  Topic 

a5972s
Starting Member

4 Posts

Posted - 2007-10-16 : 12:01:14
Hi,

I'm trying to execute a command line script to backup a database using dbbackex.exe

Can someone cast an eye over the script and let me know what the issue is. I end up with NULL output.

--Turn on Advanced features
EXEC sp_configure 'show advanced options', 1
reconfigure
go
--Turn on xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
reconfigure
go
--Run script
exec master.dbo.xp_cmdshell '"C:\Program Files\Veritas\NetBackup\bin\dbbackex.exe" -f ''"C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch"'' -p Test_Sql -u username -pw password -np', no_output
go
--Turn off xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 0
reconfigure
go
--Turn off advanced options
EXEC sp_configure 'show advanced options', 0
reconfigure
go

Kristen
Test

22859 Posts

Posted - 2007-10-16 : 12:13:19
Guessing:

exec master.dbo.xp_cmdshell '"C:\Program Files\Veritas\NetBackup\bin\dbbackex.exe" -f ''"C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch"'' -p Test_Sql -u username -pw password -np', no_output

Do you need that (doubled up) single quote in there?

Kristen
Go to Top of Page

a5972s
Starting Member

4 Posts

Posted - 2007-10-16 : 12:26:12
I get the error...
'C:\Program' is not a recognized as an internal or external command,
operable program or batch file.
NULL

..when I amend to read...

exec master.dbo.xp_cmdshell '"C:\Program%20Files\Veritas\NetBackup\bin\dbbackex.exe" -f ''"C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch"'' -p Test_Sql -u username -pw password -np'

..I get the following...

The filename, directory name, or volume label syntax is incorrect.
NULL

HELP!!

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-16 : 12:34:27
its the ones I marked up in RED that I think need removing ... or was that what you tried?

Kristen
Go to Top of Page

a5972s
Starting Member

4 Posts

Posted - 2007-10-16 : 12:38:22
..I get the following when quotes are removed...

The filename, directory name, or volume label syntax is incorrect.
NULL

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-16 : 12:45:05
(I don't think the %20 will help, as that's for a URL which probably won't be interpretted corectyl in this scenario)

Please show me the [exact] command you are trying, because what you posted earlier still has the single quotes in it.

Kristen
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-16 : 12:46:34
Actually probably save time if I show you the command I was meaning. You may have been using that one, but to avoid confusion:

exec master.dbo.xp_cmdshell '"C:\Program Files\Veritas\NetBackup\bin\dbbackex.exe" -f "C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch" -p Test_Sql -u username -pw password -np', no_output

if that doesn;t work what do you get when you type this into a Command Prompt:

"C:\Program Files\Veritas\NetBackup\bin\dbbackex.exe" -f "C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch" -p Test_Sql -u username -pw password -np

Kristen
Go to Top of Page

a5972s
Starting Member

4 Posts

Posted - 2007-10-16 : 12:47:35
exec master.dbo.xp_cmdshell '"C:\Program Files\Veritas\NetBackup\bin\dbbackex.exe" -f "C:\Program Files\VERITAS\NetBackup\DbExt\MsSql\NBU_Full.bch" -p Test_Sql -u username -pw password -np'
go

Hope this helps
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-16 : 13:38:41
OK, well that's identical to what I hoped you were running.

You'll need to try running the actual command from a Command Prompt and seeing what that says. if you can debug that then you can put whatever changes you find you need to make back into the xp_cmdshell version.

Kristen
Go to Top of Page
   

- Advertisement -