Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

handle ERROR 32 using perl script

by madtoperl (Hermit)
on Aug 05, 2010 at 15:17 UTC ( [id://853159]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks,
I would like to know if there is any module available/is it possible to resolve the system error 32 in windows machine using perl script.
Please let me know.
Thanks,
madtoperl

Replies are listed 'Best First'.
Re: handle ERROR 32 using perl script
by roboticus (Chancellor) on Aug 05, 2010 at 15:23 UTC

    madtoperl:

    Short answer: no.

    Long answer: Generally, a perl script isn't going to be able to handle a system error for you. A system error typically occurs when you ask the operating system something to do something, and the operating system can't or won't do it.

    According to http://msdn.microsoft.com/en-us/library/ms681382(VS.85).aspx, system error 32 is a sharing violation. So Windows is telling you that the file is already in use, and the current user doesn't want to share the resource. The way to handle that would be to: (a) close the other application, (b) alter the application to allow sharing, and/or (c) update the current application to report the problem and offer to let you try something else, rather than fail.

    ...roboticus

Re: handle ERROR 32 using perl script
by kejohm (Hermit) on Aug 06, 2010 at 08:57 UTC

    If what you're looking for is to resolve an error code to its description, then you can use the FormatMessage() function from the Win32 module. Example:

    C:\>perl -MWin32 my $errorcode = 32; print Win32::FormatMessage($errorcode); ^Z The process cannot access the file because it is being used by another + process.

    Update: Link fixed.

      Or assign to $^E
      $ perl -le"warn $^E=32" The process cannot access the file because it is being used by another + process at -e line 1.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-24 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found