I am not quite sure how to approach copying a remote directory off an FTP server and recreating that structure on a local FTP server. The idea is to download real estate listings on a daily basis via a cron job. The structure is broken down like this:
- File are automatically updated on the remote FTP server as scheduled via a web interface
- Format is
MI20051106_050117_X.log
MI20051106_050117_X_1.zip
where 20051106 is yyyymmdd,
050117 is (I'm guessing) hhmmss,
X is either CIB, FAL, MUL, Office, RES, and USER (may or may not be present),
_1 follows (in the case of zip files only),
and ends with .log or .zip extension.
(example of existing files:
MI20051106_050607_CIB.log
MI20051106_050607_CIB_1.zip)
Files are archived by the remote server and the last 2 pulls are kept in their respective directory, ie.
20051104_050117
20051105_050401
Each of these .zip files unzip into plain text files. They come out in a format like this:
15105|NORTHWOOD REALTY SERVICES|536811|||635 Lowries Run Road|324900|A|NAL|106001||||59000|||||||||||||||||||||||||1 Acre|||||||||OTH||||||||||||15237||212429|Information Deemed Reliable, But Not Guaranteed
Having said this, I have this script I pulled from the php.net comments, and I have it pulling the base files down to my local FTP server (meaning, script is NOT recursive).
How would you approach this? My code plan is as follows; am I missing something, or should I take another approach?
copy all remote files to local webhost
(current script does this)
change .zip files to 770
(chgrp to apache? chown to apache?)
2a. delete all .log files
unzip all zip files via UNIX
a. giving password (password-protected files)
b. deleting all ending in .zip
create folder based on first 17 characters
(ie 20051106_050607)
move all corresponding files into this newly created folder
Eve
P.S. Each of these files are incremental pulls. Would I have to create a script to add the incremental pulls to the master list as well, or should I let some code display the master list and each incremental directory?