Suppress error message in unzip


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Suppress error message in unzip

I'm creating a bsh shell to unzip a file from one directory into another. The directory that holds the zip files has zip files constantly being added to it, so I am testing it before it does the unzip and more.

Right now my code looks like this:
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME >/dev/null
if [ $? != 0 ]
then
	echo "$ZIP_NAME is not a complete file."
else
	# --- unzip file and move completed zip to new location ---
	echo "unzipping $ZIP_NAME"
	unzip -q $ZIP_PATH/$ZIP_NAME -d $DATA_DIR/$ISBN_NAME
	mv $ZIP_PATH/$ZIP_NAME $DONE_PATH/$ZIP_NAME

I'm trying to suppress the large error message that pops up in my unix screen when the unzip test fails. It continues to show up now matter what. Is there any way to make it not show up?

Mike
# 2  
Errors are written to stderr "2"
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME 2&>1 > /dev/null

# 3  
Hi.

Hmm, I don't know about bsh, but for bash, Jim probably meant:
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME 2>&1 > /dev/null

cheers, drl
# 4  
Quote:
Originally Posted by jim mcnamara
Errors are written to stderr "2"
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME 2&>1 > /dev/null

I tried that as well as some variations earlier, but the test error message won't stop popping up in the tests that I run. I get a paragraph about the end of central directory not found. It executes as it's supposed to but the error message won't go away.
# 5  
Quote:
Originally Posted by skwyer
I tried that as well as some variations earlier, but the test error message won't stop popping up in the tests that I run. I get a paragraph about the end of central directory not found. It executes as it's supposed to but the error message won't go away.
I'm not surprised it didn't work, becuse the syntax is reversed.
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME > /dev/null 2>&1

should work.
# 6  
Quote:
Originally Posted by reborg
I'm not surprised it didn't work, becuse the syntax is reversed.
Code:
unzip -tq $ZIP_PATH/$ZIP_NAME > /dev/null 2>&1

should work.
That worked. Thanks so much, everyone!

Mike
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #933
Difficulty: Medium
Microcontrollers operating within embedded systems (such as the Raspberry Pi, Arduino, and other similar systems) always have internal hardware to keep track of time.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash function to suppress warning message for specific text and display prompt

In the below bash function multiple variants are input and stored in a variable $variant, and each is written to an out file at c:/Users/cmccabe/Desktop/Python27/out.txt stored on a separate line. # enter variant phox2b() { printf "\n\n" printf "What is the id of the patient getting... (0 Replies)
Discussion started by: cmccabe
0 Replies

2. Shell Programming and Scripting

Tcsh: How to suppress error messages.

Hallo, I wrote some script: 95% of the script's output consists of error messages like "mkdir: cannot create directory ‘final’: File exists Exit 1" and "rm: No match. Exit 1". These messages are not harmful at all, but they make the output almost unreadable. How can I get rid of... (5 Replies)
Discussion started by: DanielDD
5 Replies

3. Shell Programming and Scripting

How to suppress error in following command?

I have a file containing data in multiple columns. The colums are seperated by pipe (|). I need to extract information as below: myfile_20130929_781;10;100.00 where myfile.txt is the file name. 10 is the number of records in the file starting with 120 and 100.00 is the sum of 26th field of... (16 Replies)
Discussion started by: angshuman
16 Replies

4. Shell Programming and Scripting

Suppress Error Message

How can I suppress a error message being given by awk command in bash shell? (2 Replies)
Discussion started by: Prachi Gupta
2 Replies

5. Shell Programming and Scripting

Suppress a background message in Bash

I'm having trouble with part of this bash script in Linux where I respawn a new instance of script and kill the old one to prevent forking (Yes, I know 'exec' will not fork but this needs to be interactive) When the old instance is kill it pops up "Terminated!" in the middle of the new instance... (7 Replies)
Discussion started by: Azrael
7 Replies

6. Shell Programming and Scripting

Suppress "Where are you?" Message

biff n pdir=`pwd` # check for null parameter if ; then echo current directory $pdir ls -latr echo else p1=$1 #check for directory entry only if ; then pdir=$p1 echo current directory $pdir cd $pdir ls -latr echo #check for directory entry and file... (2 Replies)
Discussion started by: wtolentino
2 Replies

7. Shell Programming and Scripting

suppress unzip queries

hey i have piece of code working in solaris and same code i want to deploy it in linux but in solaris its not asking for queris but in linux it is !!!! COMMAND ==> unzip $test/alter.war -d $webclientHome/. OUTPUT==> In solaris it proceeds with following traces replace /aa/test.txt?... (4 Replies)
Discussion started by: crackthehit007
4 Replies

8. Shell Programming and Scripting

Suppress error message in shell script

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie... (3 Replies)
Discussion started by: newbie07
3 Replies

9. Shell Programming and Scripting

How to suppress error messages in script

I am getting the following upon cat a file which is not present in directory. "cat: cannot open test1.txt" I need to process files and I want that this message should be suppressed. thx (5 Replies)
Discussion started by: helper2007
5 Replies

10. Shell Programming and Scripting

suppress bash's "Done" message

Hi, I'm running a background job in my bash script. But when the job quit, bash echos a message like "+ Done xterm". This is annoying. How can I suppress it? (5 Replies)
Discussion started by: momiji
5 Replies

Featured Tech Videos