[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

[CMDShell] Cant execute Dos Command

Sphenixs

3/19/2007 9:21:00 AM

DECLARE @COMMAND VARCHAR(5000)
DECLARE @Day VARCHAR(5)

Set @Day = 'Day01'

SET @COMMAND =
'ftp
open
192.168.253.9
ftpuser
ftpuser

prompt off

cd Report\Day01\ABCmput \Data\'+ @Day + '\*.txt

bye'
--print @command
EXEC [MASTER]..XP_CMDSHELL @command

why I cant execute this FTP command in SQL-Transact Query?

2 Answers

Tibor Karaszi

3/19/2007 11:51:00 AM

0

Try creating a file containing the FTP commands and then use the -s switch of FTP to point to that
file.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/d...
http://www.solidqualitylea...


"Sphenix" <Sphenixs@gmail.com> wrote in message
news:1174296065.041322.161080@e65g2000hsc.googlegroups.com...
> DECLARE @COMMAND VARCHAR(5000)
> DECLARE @Day VARCHAR(5)
>
> Set @Day = 'Day01'
>
> SET @COMMAND =
> 'ftp
> open
> 192.168.253.9
> ftpuser
> ftpuser
>
> prompt off
>
> cd Report\Day01\ABC> mput \Data\'+ @Day + '\*.txt
>
> bye'
> --print @command
> EXEC [MASTER]..XP_CMDSHELL @command
>
> why I cant execute this FTP command in SQL-Transact Query?
>


Daniel Crichton

3/19/2007 11:54:00 AM

0

Sphenix wrote on 19 Mar 2007 02:21:05 -0700:

> DECLARE @COMMAND VARCHAR(5000)
> DECLARE @Day VARCHAR(5)
>
> Set @Day = 'Day01'
>
> SET @COMMAND =
> 'ftp
> open
> 192.168.253.9
> ftpuser
> ftpuser
>
> prompt off
>
> cd Report\Day01\ABC> mput \Data\'+ @Day + '\*.txt
>
> bye'
> --print @command
> EXEC [MASTER]..XP_CMDSHELL @command
>
> why I cant execute this FTP command in SQL-Transact Query?

xp_cmdshell can only execute what you could normally put on a single command
line, and the above doesn't work like that.

See http://www.databasejournal.com/features/mssql/article.p... for
info on how to get it to work.

Dan