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 |