
FTP Wildcard
Moderators: JRL, Dorian (MJT support)
FTP Wildcard
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. 

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.
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]
[email protected]
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
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
================================
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!
Bob
A humble man and PROUD of it!