FTP Wildcard

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Pax

FTP Wildcard

Post by Pax » Thu Jan 23, 2003 12:10 am

I need a way to use FTPGetFile with a wildcard. The file I need to get changes everyday, but is always in the same directory. If anyone knows how to do this I would greatly appreciate any help. :?:

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Jan 23, 2003 12:22 am

Hi,

Not with Macro Scheduler commands. Either create an FTP command file (see FTP -h on command line) and do Run>FTP server.com -s:filename or issue FTP commands directly to the command line like e.g:

Run>cmd.exe /k @title=DosFTP
WaitWindowOpen>DosFTP
SetFocus>DosFTP
Send>FTP %CRLF%
Send>open ftp.server.com %CRLF%
Send>username%CRLF%
Send>password%CRLF%
Send>GET /dir/*.* c:\downloads\*.*%CRLF%
Send>quit%CRLF%
Send>exit
Press Enter

sending %CRLF% at end of lines saves doing Press Enter between each line. Works nicely and makes it easy to add variables etc.

The first bit works in NT,2K,XP to allow you to change title of DOS box for easy focusing. In 95/98/Me use command.com instead.
MJT Net Support
[email protected]

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jan 23, 2003 2:21 am

I just did a quick "Cut/Paste" from a script that I run every week. All of the FTP paramaters are defined earlier with Let> statements. The file name changes every week, and I use an Input> command to prompt for the desired filename. If you know the algorithm for the file naming, then this manual entry could be automated with some code to define %ftpfilename% before the Retrieve section.
================================
Label>Start
.....
.....
.....

//Retrieve file from FTP site
FTPGetFile>%FTPServer%,%FTPUser%,%FTPPW%,21,%ftpfilename%.zip,%ftpfilename%.zip,I

//Confirm download and delete from FTP, disconnect FTP.
//Does not use next line to Delete, because it would always exist. Need to check file size instead.
//IfFileExists>%ftpfilename%.zip,DeleteFTP
Let>ftpfilesize=0
FileSize>%ftpfilename%.zip,ftpfilesize
If>%ftpfilesize%>0,DeleteFtp
MessageModal>File not downloaded
Goto>Start

//Delete file from ftp site
Label>DeleteFtp
FTPDelFile>%FTPServer%,%FTPUser%,%FTPPW%,21,%ftpfilename%.zip
.....
.....
.....
Label>End
============================
Additional lines may be included to make multiple attempts on FTP failures. Not shown here to simplify model.

Note, that my scripts usually include non-working lines to prevent future changes that will fail.

Hope this was helpful
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Paxer

Algorithm

Post by Paxer » Thu Jan 23, 2003 5:37 pm

The file would be date then a sequence number, which would increase by one everytime the script is run. I don't know if that changes anything or not. Thank you for your help, I will give those a try and see if I can get it going.

maxipad

Post by maxipad » Thu Jan 23, 2003 6:34 pm

You're gay!!!!! :lol:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts