Re: copy an epub as a file, not a directory
by choroba (Cardinal) on Sep 12, 2019 at 21:25 UTC
|
How do you "copy" a file from a directory to a local Apache web site? File::Copy can copy files, but it doesn't change them into directories, and can't copy to a site.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] |
|
|
Sorry for any confusion. I run an Apache web server on my local iMac and do all my development here before uploading to my host.
My Perl script copies an epub from my Desktop to a local directory for testing the local web site. This is where I'm running into problems.
The commands I'm using are:
my @sys=("cp", "-R", "-i", "/Users/user/Desktop/$FileName", "/Volumes/Backup3/httpd/public/local/fiction/data/$Author/$FileName");
system(@sys) == 0 or die "system cp failed: $?";
When I access the library web site, it shows me list of recent files which are clickable. Previously I could click a file (in Safari), and it would download fine. But now it's throwing an error:
'Forbidden. You don't have permission to access /fiction/data/Baldacci,David/Saving Faith.epub/ on this server.'
This is where 'ls' tells me that file is a directory, not a file.
| [reply] |
|
|
First, you should not be giving cp the -R flag if you are intending to copy files rather than directories.
Second, now we know that we are looking at a Macintosh... Classic MacOS files had both data and resource forks. In MacOS X, most of the system plays games where a "file" can actually be a directory in the underlying *nix environment to emulate the classic resource fork. Long story short, are you sure that the "files" on your desktop are actually files?
| [reply] |
Re: copy an epub as a file, not a directory
by jcb (Parson) on Sep 12, 2019 at 22:43 UTC
|
Presumably, a "local Apache web site" is a directory in the filesystem somewhere? As choroba mentioned, Perl should not be magically unpacking ZIP archives while copying them.
Is "'ls'" the system ls command, examining that local directory that Apache is serving files from?
Check your Apache configuration: are you using some kind of module that magically translates ZIP archives to directories?
There is some kind of magic that has been set up here that needs to be dispelled. Can you post the Perl code that copies the files, preferably as an update to your post?
| [reply] |
|
|
Thank you for your input. This is frustrating to me because this script DID work for many books, and only recently has it gone wonky. Hence my posting here.
Yes, the 'ls' is the OSX system command. Under that author here is what ls tells me:
ls -al "/Volumes/Backup3/httpd/public/local/fiction/data/Baldacci,Davi
+d"
-rw-r--r--@ 1 user admin 3115762 Feb 13 2019 End Game.epub
drwxr-xr-x 6 user admin 204 May 30 2016 Saving Faith.epub
As you can see 'Saving Faith' is a directory, and only 204 bytes. But in Finder it shows up as 1MB and opens in iBooks.
As for other possibilities, I haven't altered the Apache config for years - if it works I leave it alone. No modules in there.
Something screwy in Skagway here :) | [reply] [d/l] |
|
|
Did it stop working after an OSX update? As I mentioned in another reply, MacOS X plays games like this.
The actual epub file is probably in that directory somewhere, so you will need to improve your Perl script to check if the "file" that it has been asked to copy is actually a directory (the -d file test operator should help here) and, if so, search within to locate the actual file and copy the real file and not the Apple "file".
| [reply] [d/l] |
|
|
|
|
|