how to detect errors in unzip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to detect errors in unzip
# 1  
Old 02-22-2006
how to detect errors in unzip

Hello

I am trying to write a script that internally will invoke unzip on some .zip file
I would like to make my script robust by checking for any possible error that might occur during the unzipping.

Are there any arguments that I can add to the unzip command which will let me know if an error occurred during the unzipping process?
then I will check for these errors in the

thanks
# 2  
Old 02-22-2006
Make use of the special variable $?. It holds the exit status of the command just executed.

Have something like this in your script.

Code:
unzip file.zip
if [[ $? == 0 ]] ; then
echo "Success"
else
echo "Some failure."
fi ;

Look into man unzip for the types of possible errors that can be encountered.
# 3  
Old 02-22-2006
thanks for the answer
I would like to test my code by intentionally causing a problem
For example,
assume that I have a file called test.txt
I would like to zip test.txt into test.zip
The I want to lock test.txt somehow
next I will try to unzip test.zip. but since it tries to write into a locked file,
I hope the unzip will fail

Will that work?
if so, how can I lock a file in linux and then unlock it
I am using putty to interact with linux so all I have is a simple command shell

thanks in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unzip

Hi All, I am having an error with a zip . It is showing me the below error. I tried using zip and jar command all show me the same error. Not sure what is this error and why this is coming any help ? >>> jar -xvf 99999_zpd.zip extracted: 100793_ipd0000.001.gz extracted:... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

3. UNIX for Advanced & Expert Users

Unzip help

Hi, client is posting a zip file with named as "LM_SEEHERE_-_TMG_905678_20100504.zip". In zip file, inside we have 3 .csv files. how to unzip the file and client needs only "LM_SEEHERE_-_TMG_905678_20100504.csv" the other two files are products.csv,category.csv. They don't want these files... (2 Replies)
Discussion started by: kirankumar
2 Replies

4. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

5. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

6. UNIX for Dummies Questions & Answers

catch unzip errors

Hi everybody, I'm new to linux world and I need your help!! I'm using vi to create a .sh script that process files moving them from a directory to another and unzipping a file. I need to catch errors while moving or unzipping files. For move command, I do: mv -f... (2 Replies)
Discussion started by: Laetitia
2 Replies

7. UNIX for Dummies Questions & Answers

Major OS errors/Bash errors help!!!!

Hi all, dummy here.... I have major errors on entering the shell. On login I get: -bash: dircolors: command not found -bash: tr: command not found -bash: fgrep: command not found -bash: grep: command not found -bash: grep: command not found -bash: id: command not found -bash: [: =: unary... (12 Replies)
Discussion started by: wcmmlynn
12 Replies

8. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

9. AIX

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (2 Replies)
Discussion started by: mcastill66
2 Replies

10. UNIX for Advanced & Expert Users

Adapter Errors and Link Errors

$ errpt | more IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 3074FEB7 0802050205 T H fscsi1 ADAPTER ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR B8113DD1 0802050205 T H fcs1 LINK ERROR 3074FEB7 0802050205 T H fscsi0 ADAPTER ERROR B8113DD1 ... (0 Replies)
Discussion started by: mcastill66
0 Replies
Login or Register to Ask a Question