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)
 ftp on error re try

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2013-01-28 : 02:37:11
Hi,
I am using the below command to download the file from FTP. But i want to ensure if there is no files exist we need to alert a TEAM saying its not there.How can we achieve this ??

SET @cmd = 'del E:\ARK\AT\cmds.txt /Q'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo username_XXX>> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo password_YYY >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo lcd E:\ARK\AT >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo cd /A/updates >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo mget *' + dbo.AtDate() +'.* >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo quit >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'ftp -i -s:E:\ARK\AT\cmds.txt ftp.XXX.com'
EXEC master..xp_cmdshell @cmd



Thanks,
Gangadhara MS
SQL Developer and DBA

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-28 : 03:36:42
do a dir on file pattern and take the count and check if its >0 before you do above

wrap the entire code in a batch file

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2013-01-28 : 21:40:22
thanks visakh for suggestion

could you pls some script to count the files ..i am sorry i am not much versed with ftp commands.

Thanks,
Gangadhara MS
SQL Developer and DBA
Go to Top of Page
   

- Advertisement -