FTP task

I have a task that exports data from Salesforce to a flat file on the server where the secure agent is running.  I use a post processing command to copy the data from the target file to a new file with the date appended to the end of the file name using the following command:

copy c:\TargetTemplate.txt
c:\FileName_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt

After the task runs, I need to take the file that was created and FTP it to another server.  I can access the FTP server, but how do transfer the file?  I created a new FTP connection and tried to create another data service task, but I'm not sure how to setup the source and the target?

The source file is never the same because the date is appended to the end of the file name and it doesn't even exist when I'm trying to create the new task.

What is the best automated option to use FTP and transfer the file?

Thanks for any help.
-Dman100-Software ConsultantAsked:
Who is Participating?
 
ApothisCommented:
Okay, i don't have an sftp server to test with, but you should be able to modify my previous script slightly to use fzsftp.exe, located in the install directory of FileZilla client. If mput doesn't work, -copy should.
0
 
ApothisCommented:
I created this awhile back to batch upload ads from our advertising database using a .bat file with a scheduled task.
cd e:\GRA-Public\Daily FTP Upload\Auctions
ftp -i -s:"C:\ftp\Auctions\script.txt"

Open in new window

Then here is the contents of script.txt
open ftp.server.com
username
password

cd httpdocs/displayads/auctions

mdelete *
binary
mput *
bye

Open in new window

The mdelete * deleted everything in the destination before uploading, so you might want to change that, then mput * uploaded everything from the local directory (e:\GRA-Public\Daily FTP Upload\Auctions) to the remote server (httpdocs/displayads/auctions).
0
 
lcohanDatabase AnalystCommented:
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
-Dman100-Software ConsultantAuthor Commented:
Thank you for responding to my post.  The bat file option will probably work best.

A couple of questions.  I need to use port 22.  Do I need to specify that in the script file?  If so, how?

Also, the documents I'm transferring are in the c:\ root directory, so I don't want to transfer everyting in the c:\ directory.  Is there a way to specify only the files that start with a file name of: "Ag_Spend"?  The end of the file name will always be appended with the current date so that changes dynamically.  I only need to transfer the files that start with "Ag_Spend".

Thanks again for your help!
Regards.
0
 
ApothisCommented:
As for using port 22, are you trying to use sftp? If so, then you would need to install a command line sftp client, i believe FileZilla has command line arguments, but that would be a different script altogether. If you are just using ftp on port 22, then I believe the open line would read:
open ftp.server.com:22

Open in new window

I don't have a way to test that though at this time.

As for only grabbing Ag_Spend, the mput line should read:
mput Ag_Spend*

Open in new window

0
 
lcohanDatabase AnalystCommented:
Below is a list with all FTP commands:

http://www.nsftools.com/tips/MSFTP.htm
0
 
ApothisCommented:
So based on the info from lcohan, the open line should read:

open ftp.server.com 22

Open in new window


This assumes you are connecting to an FTP server, and not a SFTP server.
0
 
-Dman100-Software ConsultantAuthor Commented:
Ah, yes, I am using SFTP server.  How would that change the script? Also, I could install WinSCP on the server.  Would that work?
0
 
eksatxCommented:
I recommend using Robo-FTP (http://www.robo-ftp.com). It supports SFTP (along with FTP, FTPS, HTTP, and HTTPS).

It offer some important advantages over trying to automate this with a batch file.

Much more secure -- no need to store password in plain text.
Much more reliable -- Robo-FTP offers error handling to retry failed logins, broken uploads, etc.
Easier to implement, deploy, and maintain -- it is designed from the ground up for automating tasks.
0
 
ApothisCommented:
I will try to get you a working script with instructions on install and use today.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.