Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

command prompt locks scripts for editing

by inman (Curate)
on Jun 02, 2006 at 14:43 UTC ( [id://553305]=perlquestion: print w/replies, xml ) Need Help??

inman has asked for the wisdom of the Perl Monks concerning the following question:

I have encountered a frustrating error that stops me from editing and testing a script in Windows XP SP2. I would like to know whether anyone has encountered the same thing and whether it can be fixed.

I have just re-installed Perl and restored my data as I had to get a new hard disk following the failure of my old one. The software image is provided by my company and is Windows XP service pack 2 with the latest security updates. I have installed the latest vesrion of Activestate Perl (v5.8.8).

When it comes to development, my method of working is to edit the script and then test it in a command prompt (CMD.EXE) before making changes and testing again using the same instance of the command prompt. The problem surfaced when I tried to save the changes to the script and my editor told me that the file was locked (file unavailable or readonly) by another process.

I have done a fair bit of investigation and come up with the following:

  1. The problem is limited to a script executed via the extension association. Running myscript.pl at the command line will lock the source file. If I use perl myscript.pl there is no problem.
  2. The script itself runs as expected even though the source cannot be edited.
  3. I have tested various other situations where the file association is used (E.g. running the script from Explorer) and not had a problem.
  4. The source file is locked (reported as readonly) until the CMD.exe instance is closed.
  5. The inability to edit has been verified with standard tools such as notepad and edit in order to remove the editor form the problem.

The only concludion that I can draw is that CMD.EXE is somehow holding on to the file after it has been executed in the way described.

Is anyone else able to reporoduce this issue? Although, I can work around the problem but I am finding it particularly frustrating!

cheers

Replies are listed 'Best First'.
Re: command prompt locks scripts for editing
by traveler (Parson) on Jun 02, 2006 at 15:18 UTC
    I have not seen this in a similar environment.

    Is it possible that you have a GUI in your script and that invisible windows are still around? Check the task manager.

    HTH, --traveler

Re: command prompt locks scripts for editing (sysinternals)
by tye (Sage) on Jun 02, 2006 at 22:15 UTC

    You should go to http://www.sysinternals.com/ and grab a tool (like Handle) that will show you who really has the file open. It might be cmd.exe or it might be something else that cmd.exe launches that goes away when cmd.exe's console goes away. Perhaps it is something that you can 'kill' to make working around the problem easier.

    There are also other tools that will let you monitor what is going on such that you might be able to figure out how to prevent the problem.

    I'd think that Perl would not even leave the script open unless you had a __END__ / __DATA__ in it. If so, closing DATA in your script may prevent the problem (yes, I'm not assuming that cmd.exe is what is keeping the file open at this point).

    - tye        

Re: command prompt locks scripts for editing
by girarde (Hermit) on Jun 03, 2006 at 19:51 UTC
    From your description I am not certain if this is particular to one script or common to all. If is particular to one, source code would help.

    I work in XPsp2 as well, but do not experience this problem.

    If you test before saving changes, how do you test the changes? The version that runs is in the file on disk, not in the editor's buffer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://553305]
Approved by dsheroh
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-04-25 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found