|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
FTP File Check
I have a database of about 3000 files. On a diffrent server I have the corsoponding files aviaiable via FTP. Recently I discover one of the people that was helping me was entering file names into the database but not putting the files on the FTP server so that users are getting broken links.
I thought I could use LWP to confirm each file. I can certainly download each file as a way to confirm it but this is time and bandwidth consuming. Is there a way with LWP to have it simple respond weather the file exists or not? Been looking through docs but I'm not seeing it and it seems like such a basic feature I can't believe that it's not there. |
|
#2
|
||||
|
||||
|
There is, and you dont need LWP for that... just use the -e switch to test for existence. You can then print the results to the screen.
Loop through your array of filenames: print "$filename not found" unless (-e "$filename");
__________________
webM for $i(0..20){for($j=0;$j<=$i;$j+=2){print pack(qq{H2}, substr(qq{5f5745424d415354415f},$j,2));}print qq{\n};}; |
|
#3
|
||||
|
||||
|
I usually use Net::FTP for this sort of thing, which has two functions that might help.
size($filename) returns (obviously) the size of the file. If the file doesn't exist, it returns undef. Code:
foreach (@filenames) {
print "$_ not there\n" unless (defined $ftp->size($_));
}
Alternatively, if all the files you're interested in are in the same directory, get a directory listing and process that. This is probably quicker as it reduces the number of transactions with the FTP server. Code:
my @files_on_server = $ftp->ls(); |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > FTP File Check |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|