Solved

FTP task

Posted on 2012-03-28
10
831 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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:-Dman100-
Comment Utility
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
Comment Utility
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
Comment Utility
Below is a list with all FTP commands:

http://www.nsftools.com/tips/MSFTP.htm
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Expert Comment

by:Apothis
Comment Utility
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-
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
CDC audit 17 84
Compare data between two databases 16 81
What is ISQL? 6 99
Data center mess 4 45
This article describes some very basic things about SQL Server filegroups.
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

11 Experts available now in Live!

Get 1:1 Help Now