Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FILE FILTER FOR FTP 1

Status
Not open for further replies.

Volkmaniac

Technical User
Mar 19, 2003
104
US
Is there anyway I can use a file filter for ProComm's ftp? I want to upload every file that's in the remote directory to the local. Each of those files has an input mask of ARS-N*. How would I need it to either upload every file in the directory or upload all the files that begin with ARS-N*

Here is the script I took from aspect:

proc main

FTP LOCAL CHDIR "S:\Client Services\LETTERS\" ;Set the local dir. to S:\Client Services\LETTERS\.
Connect FTP "RS6000" ;Connect to our FTP site.
while $ftpstatus ;Loop while connecting to FTP site.
yield
endwhile
pause 1 ;Let Procomm update its screen.
FTP REMOTE CHDIR "/tmp/ars/letters/" ;Change dir on FTP site.
pause 1
FTP REMOTE COPYFILE "*" ;Copy (download) * from FTP
;site to local machine. Filenames
;are case-sensitive!
while $ftpstatus ;Yield while transferring file.
yield
endwhile

pause 1 ;Let Procomm update its screen.
FTP REMOTE CHDIR "/upload/" ;Change dir on FTP site to /upload/.
pause 1 ;Let Procomm update its screen.
FTP LOCAL COPYFILE "*" ;Copy (upload) file to FTP site.
while $ftpstatus ;Yield while transferring file.
yield
endwhile
disconnect
endproc
 
Here is some code to set the remote filter and store the directory listing in a locale file

set ftp filter remote "ARS-N*"
sendvkey 0x74
pause 1
ftp remote filelist "c:\foo.txt"

The sendvkey command refreshes the file listing after you have set the filter.

There is no way in ASPECT to download all files automatically from the remote site. You'll need to open the filelist and trasfer each file one-by-one.


aspect@aspectscripting.com
 
Thanks. I have to leave right now but I'll try it first thing Monday. Thanks again for all your help this week.
 
OK,

Thanks for your help. I'm able to copy the filoes from the remote to the local host. However, for whatever reason the file list I created is copying two of each file. In other words, if I have two files to copy the filelist is listing them twice.

proc main

string fname


FTP LOCAL CHDIR "S:\Client Services\LETTERS\" ;Set the local dir. to S:\Client Services\LETTERS\.
Connect FTP "RS6000" ;Connect to our FTP site.
while $ftpstatus ;Loop while connecting to FTP site.
yield
endwhile
pause 1 ;Let Procomm update its screen.
FTP REMOTE CHDIR "/tmp/ars/letters/" ;Change dir on FTP site.
pause 1
set ftp filter remote "ARS-N*"
sendvkey 0x74
pause 1
ftp remote filelist "S:\Client Services\LETTERS\files.txt"
pause 3
fopen 0 "S:\Client Services\LETTERS\files.txt" read text
while not feof 0
fgets 0 fname
if not nullstr fname




FTP REMOTE COPYFILE fname ;Copy (download) * from FTP
endif
endwhile ;site to local machine. Filenames
;are case-sensitive!
while $ftpstatus ;Yield while transferring file.
yield
endwhile

pause 1 ;Let Procomm update its screen.

disconnect
endproc
 
OK,

I took out the set ftp filter remote "ARS-N*" portion and it's working fine. I really don't need that because there aren't going to be multiple file types in that directory.

Thanks again for all your help.
 
Did removing the filter take care of the duplicate file problem? You may need to delete files.txt at the end of your script in case the ftp remote filelist command is appending to that file instead of overwriting it.


aspect@aspectscripting.com
 
removing the filter did take care of the problem. Once the files get copied to the local drive they're zipped using the zip script. Now I need to ftp that zipped file to another ftp site. However, that file is in a drive with multiple zipped files according to their date. I need to only grab the zipped file with the latest date so I can ftp it over. Is there a script that will allow me to grab either the last file that was zipped or the zipped file with the latest date?
 
If the naming convention is constant (basefilenameMMDDYY for example), then you could read each filename from the filelist and parse out the date portion of the filename. Save this to a string variable if the date portion is greater than the currently-saved value (and save the full filename to another variable so you know which file to transfer). I would recommend converting the date substring to an integer using the atoi command to ease the checking of its value. Continue reading each file from the filelist until you have determined which is the latest file.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top