dbTalk Databases Forums  

Can the ftp task take wildcards?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Can the ftp task take wildcards? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
JRStern
 
Posts: n/a

Default Can the ftp task take wildcards? - 04-19-2005 , 06:34 PM






I finally got it to do single files, even multiple files, but only
with full names. Can't it do a template, eg myfile_200504*.txt?

Note that standard command-line FTP has mget.

Thanks.

Josh


Reply With Quote
  #2  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: Can the ftp task take wildcards? - 04-20-2005 , 07:48 AM






I prefer using ftp from the commandline instead of the FTP task, because of
the limited functionality of it.

You call ftp with a Execute Process Task or xp_cmdshell:
EXEC master..xp_cmdshell 'ftp -v -s:<your file here>'

You can create the command file you pass to ftp with xp_cmdshell as well,
and with some DOS trickery, you can even combine the two:

exec master..xp_cmdshell 'Echo Open 1.2.3.4 >C:\ftp.txt &&
echo user >>C:\ftp.txt && echo dev >>C:\ftp.txt && echo
pdev >>C:\ftp.txt && echo get
LUX1MCH.LUX "\\localserver\share\dir\file.ext"
Quote:
C:\ftp.txt && echo bye >>ftp.txt && ftp.exe -v -
s:c:\ftp.txt && del c:\ftp.txt'

basically we tell DOS (through xp_cmdshell) to create the
script file, write in the IP address and user and password
and everything else to execute our data transfer using
FTP, then delete the script file - all in one line of
code...


--
Jacco Schalkwijk
SQL Server MVP


"JRStern" <jxstern (AT) bogus (DOT) com> wrote

Quote:
I finally got it to do single files, even multiple files, but only
with full names. Can't it do a template, eg myfile_200504*.txt?

Note that standard command-line FTP has mget.

Thanks.

Josh




Reply With Quote
  #3  
Old   
JRStern
 
Posts: n/a

Default Re: Can the ftp task take wildcards? - 04-21-2005 , 08:31 PM



On Wed, 20 Apr 2005 13:48:14 +0100, "Jacco Schalkwijk"
<jacco.please.reply (AT) to (DOT) newsgroups.mvps.org.invalid> wrote:
Quote:
You can create the command file you pass to ftp with xp_cmdshell as well,
and with some DOS trickery, you can even combine the two:

exec master..xp_cmdshell 'Echo Open 1.2.3.4 >C:\ftp.txt &&
echo user >>C:\ftp.txt && echo dev >>C:\ftp.txt && echo
pdev >>C:\ftp.txt && echo get
LUX1MCH.LUX "\\localserver\share\dir\file.ext"
C:\ftp.txt && echo bye >>ftp.txt && ftp.exe -v -
s:c:\ftp.txt && del c:\ftp.txt'
Hmm, didn't know the trick about deleting the file with the same
statement, if indeed that's a good practice, but yeah, we have some
existing code that looks a whole lot like this.

You can also use some fancy VBScript to do shell commands (I forget
where I googled this from):

Set objShell = CreateObject("WScript.Shell")
Set objScriptExec = objShell.Exec("ipconfig /all")
strIpConfig = objScriptExec.StdOut.ReadAll
WScript.Echo strIpConfig

Good for getting a list of available files.

J.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.