Avatar of amukta
amukta

asked on 

check to see if a file is locked

Hi!

How do we check to see if a .rar/.zip file is locked, using SSIS? If it is locked, then the package should stop executing. If the file is not locked, then it should unzip/extract/decompress the file using pkzip in the execute process task. How do we accomplish this using SSIS 2005. We should be using only PKZIP to decompress the file. What is the command that should be used to unzip/extract/decompress the file using pkzip.

Thanks  a million in advance.

Any logic/code is greatly appreciated. Can someone help me with this ASAP. I'm not permitted to install any additional zip/unzip software on the server.

I greatly appreciate your help ASAP.
Microsoft SQL ServerSSIS

Avatar of undefined
Last Comment
DcpKing
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of DcpKing
DcpKing
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of amukta
amukta

ASKER

Thank you Mike,

I need to only unzip the files if they are not locked.if atleast one file is locked, my SSIS package should stop executing.i found some code online to check to see if the files are locked. But the file status of .rar/.zip is always always being shown as locked, even when they are not locked. Is there any special way of checking these files using a script task?
Avatar of AlexPace
AlexPace
Flag of United States of America image

What if you did something that would fail if it is locked?

Like maybe use a script task to rename myfile.zip to myfile.ready.zip or move the file into another subfolder named ..\ready or something like that.

Maybe even use error handling and a loop.... if it fails, pause 30 seconds and try again... for up to a max of 10 retries....  that would be pretty cool.  You could make it send an email if it was still locked after the max number of retries.
Avatar of DcpKing
DcpKing
Flag of United States of America image

I think you may be looking in the wrong place if you're seeing the .zip files as always locked - or else the creation program hasn't finished with them yet.

You might try running the unzip on them from a batch file and seeing - if they unzip regardless then it really doesn't much matter whether you think that they're locked or not ...

Mike
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo