On Jun 2, 2005, at 10:16 AM, Bill Stephenson wrote:
So I guess what I'm asking is if there a way to get either of these
apps to upload a file with a new name and rename it after the upload
is complete with one click. Obviously, this doesn't entirely solve
the problem, but it does reduce the potential.
Actually, it *would* entirely solve the problem. Renaming a file is
an atomic operation, there's no point at which anybody could get a
partial file. People still reading the old file would be fine too,
even if the rename happened while they're in the middle of reading;
the old file is readable until they close it.
Peter pointed out in a private email that this isn't reliable using
FTP's rename functionality (if your FTP even supports it) - what I
meant in the above, though I wasn't clear, was to use /bin/mv on the
server, not a rename through the FTP connection.
-Ken
Thank you to everyone for the help.
Peter provided a great explanation about why FTP is not suited for this
problem. I played with the Applescript "Script Recorder" and didn't get
too far, there may be a way to use Applescript, I just don't know much
about it.
Here's what I did come up with to make this easier for me..
Open the file from the remote server with BBEdit.
Use the "Save a Copy to FTP Server" menu command and save the file with
a new name
Then I wrote this cgi script on the remote server to chmod and rename
the file...
===========================================================
#!/usr/bin/perl
use strict;
use warnings;
use CGI;
use CGI::Carp('fatalsToBrowser');
my $Q = new CGI;
print $Q->header;
print $Q->start_html;
my $mode = 0755;
chmod $mode, 'app.cgi-new' or die ("Error 1: $!");
rename("app.cgi-new","app.cgi") or die("Error 2: $!");
print "All Done";
print $Q->end_html;
===========================================================
This isn't as good as I'd like, but it's easier than what I did before.
I know this solution now takes this pretty much way OT and so I
apologize...
Kindest Regards,
--
Bill Stephenson