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

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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

cd httpdocs/displayads/auctions

mdelete *
mput *

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).
lcohanDatabase AnalystCommented:
-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!
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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

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

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.
-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?
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.
I will try to get you a working script with instructions on install and use today.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.