Solved

FTP task

Posted on 2012-03-28
10
846 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 39

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
 
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 39

Expert Comment

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

http://www.nsftools.com/tips/MSFTP.htm
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Help Entering Data For Personnel in Excel Workbook 12 93
MS Access 2003 Query 2 52
Best RAID for a BDD Oracle 4 62
Need a starter for ETL protocol? 4 44
Note: You must have administrative privileges in order to configure lead or case queues. Salesforce.com (http://www.Salesforce.com) is a cloud-based customer relationship management (CRM) system. It is widely used around the world by sales and ma…
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now