Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FTP task

Posted on 2012-03-28
10
Medium Priority
?
908 Views
Last Modified: 2016-02-17
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.
0
Comment
Question by:-Dman100-
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 5

Expert Comment

by:Apothis
ID: 37778703
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
 
LVL 40

Expert Comment

by:lcohan
ID: 37778869
0
 

Author Comment

by:-Dman100-
ID: 37779006
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Apothis
ID: 37779102
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
 
LVL 40

Expert Comment

by:lcohan
ID: 37779135
Below is a list with all FTP commands:

http://www.nsftools.com/tips/MSFTP.htm
0
 
LVL 5

Expert Comment

by:Apothis
ID: 37779283
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
 

Author Comment

by:-Dman100-
ID: 37779316
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
 
LVL 6

Expert Comment

by:eksatx
ID: 37783144
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
 
LVL 5

Expert Comment

by:Apothis
ID: 37786982
I will try to get you a working script with instructions on install and use today.
0
 
LVL 5

Accepted Solution

by:
Apothis earned 2000 total points
ID: 37796045
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question