473,788 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to lock a file in ftp site

hi all

am trying to write some information into the file, which is located in
ftp, and this file can be updated by number of people, but if at all i
download a file from the ftp to my local machine, update it and then
upload it back to ftp, and at the same time if some one else downloads
the same file for the modification, then the data will be overwritten.

so is there a way in Python script where i can lock the file, so that
no one updates it until i release the lock.

Or is there a way where i can directly update the file from the ftp
itself, i mean without downloading it to my local machine.

Thanks in advance for the help

regards
yogi

Dec 19 '05 #1
4 2262
No, I think you have to manually set this policy directly on the ftp server.
Dec 19 '05 #2
mu*******@yahoo .com wrote:
hi all

am trying to write some information into the file, which is located in
ftp, and this file can be updated by number of people, but if at all i
download a file from the ftp to my local machine, update it and then
upload it back to ftp, and at the same time if some one else downloads
the same file for the modification, then the data will be overwritten.

so is there a way in Python script where i can lock the file, so that
no one updates it until i release the lock.

Or is there a way where i can directly update the file from the ftp
itself, i mean without downloading it to my local machine.

Thanks in advance for the help

regards
yogi

I've come across this problem - instead of uploading the file to it's

intended directory, upload it to a temp directory, with a unique name
(say uuuuuyyyymmddhh mmss where uuuuu is username and the rest are
obvious) and then *rename* it to it's correct name in the real
destination directory. Do the move in a try... except block and if it
fails, take evasive action.

In FTP a rename (i.e. move) is usually an atomic action but an upload is
not. You have an unavoidable race condition here trying to lock a file
(even if ftp allowed it) but with the method described above, you can
avoid it, but get the same effect.

Hope that helps!
-andyj

Dec 19 '05 #3
<mu*******@yaho o.com> wrote:
hi all

am trying to write some information into the file, which is located in
ftp, and this file can be updated by number of people, but if at all i
download a file from the ftp to my local machine, update it and then
upload it back to ftp, and at the same time if some one else downloads
the same file for the modification, then the data will be overwritten.

so is there a way in Python script where i can lock the file, so that
no one updates it until i release the lock.
A common means of cooperative file locking is to use the existence of
a second file as a lock indicator. I'm not sure that can be done over
FTP, though, because I think when you write to such a file you can't
tell whether it existed previously (which would mean someone else
owned the lock).
Or is there a way where i can directly update the file from the ftp
itself, i mean without downloading it to my local machine.

Thanks in advance for the help


You should probably switch from FTP to a version control system, such
as CVS or Subversion. They don't normally use locking, but they do
detect conflicting changes and stop you from overwriting other
people's changes.

--
Ben Hutchings
Every program is either trivial or else contains at least one bug
Dec 20 '05 #4
Ben Hutchings wrote:
<mu*******@yaho o.com> wrote:
hi all

am trying to write some information into the file, which is located in
ftp, and this file can be updated by number of people, but if at all i
download a file from the ftp to my local machine, update it and then
upload it back to ftp, and at the same time if some one else downloads
the same file for the modification, then the data will be overwritten.

so is there a way in Python script where i can lock the file, so that
no one updates it until i release the lock.

A common means of cooperative file locking is to use the existence of
a second file as a lock indicator. I'm not sure that can be done over
FTP, though, because I think when you write to such a file you can't
tell whether it existed previously (which would mean someone else
owned the lock).

Well of course you could place a lock on the lock file before you tested
for its presence by creating another file ...
Or is there a way where i can directly update the file from the ftp
itself, i mean without downloading it to my local machine.

Thanks in advance for the help

You should probably switch from FTP to a version control system, such
as CVS or Subversion. They don't normally use locking, but they do
detect conflicting changes and stop you from overwriting other
people's changes.

I'm not sure a version control system is right for the OP's needs, but
clearly unadorned FTP isn't going to hack it either.

This being the Python, of course, it would be relatively simple to
design a protocol that would provide the required functionality and then
build clients and servers for that protocol. But we don't know whether
that's an option yet.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
16138
by: xmp333 | last post by:
Hi, I know the noresize attribute will keep the user from resizing a frame, but is there a way to keep a frame from being resized by the browser (in response to things like different layouts/sizes on the page)? Basically I want my frame sizes to remain fixed no matter what happens.
3
11709
by: jamie | last post by:
Hi, I'm trying to delete a whole bunch of records and keep getting the message "File Sharing Lock Count Exceeded (Error 3052)". What is this error and how do I overcome it? Thanks guys.
3
1525
by: R.A. | last post by:
Hi I have the web pages developed using c#. When I change the http to https the lock showing the secure site is not showing. Is there more beside changing the http to https to convert the web page to secure? Thanks
3
1709
by: Bryan Shaw | last post by:
I do not want my users to be able to copy and paiste anything on these web pages, which will be on an internal web site. Is there a way to prevent the printing of a web page? Is there a way to lock the PrtScn key from doing a screen shot? Thanks! Bryan Shaw bshaw@amerexenergy.com
14
3839
by: Gary Nelson | last post by:
Anyone have any idea why this code does not work? FileOpen(1, "c:\JUNK\MYTEST.TXT", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared) Dim X As Integer For X = 1 To 26 FilePut(1, Chr(X + 64)) Next Lock(1, 5, 10)
4
1451
by: David Veeneman | last post by:
Is there any way to forcibly release a lock on a text file, so that it can be deleted? I am testing an order-processing site that saves transaction information in a text file that it attaches to its merchant notification. In most cases, it works fine, but occasionally a lock on the text file won't get released. When the next transaction comes along and tries to write over the file, the server throws an IO error, saying that the file is...
5
4098
by: pgdown | last post by:
Hi, I have several processes accessing files from one folder, but only one process should ever access each file. Once one process has the file, no other process should be allowed to access it, even after the first process is finished with it, except in the case where the first process crashes. In pseudo code.. * Open file with exclusive lock * Process file - failure will throw exception, skipping 'Remove
2
2626
by: WingSiu | last post by:
I am writing a Logging util for my ASP.NET application. I am facing mulit process problem. I developed a class LogFactory, and have a method called Get_Logger to create a FileLogger, which will write text into a text file. // sample code FileLogger logger = LogFactory.Get_Logger(); logger.Log("Message here");
1
2218
by: graphicguru | last post by:
Hi i got some javascript from (*) these site for lock one column with js and header row with css. i am not a programmer i am a designer. i am working in a small company. i don't find such programmer/program that helps me in this situation. i got add rows from this site: * http://www24.brinkster.com/scriptbreaker/home.htm i got lock columns from this site:
0
9655
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.