The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Handling ftp error vivek_damodaran Shell Programming and Scripting 1 06-23-2008 10:37 PM
need advice on AWK kekanap Shell Programming and Scripting 14 04-22-2008 05:01 AM
Any advice would help liquidstyleb Red Hat 2 03-05-2008 07:44 AM
Error Handling in Korn Shell scripts bhgopi UNIX for Advanced & Expert Users 4 09-06-2005 06:44 PM
Need advice: Awk vs something else? yongho UNIX for Dummies Questions & Answers 1 06-13-2005 09:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-11-2008
sureshg_sampat sureshg_sampat is offline
Registered User
  
 

Join Date: Nov 2006
Location: Czech Republic
Posts: 49
Error Handling -pls advice

Dear friends,

I am using the below command in my unix script
-----------------------------------------------
File_Name=`ls $CTRY*$DATE_SUFFIX*zip` --> Command-1

.....
if [ -f $FTP_DIR/$File_Name ]
then
unzip -a $File_Name -d $CTRY_DIR/$CTRY
else
echo "File for $CTRY dated $DATE_SUFFIX does not exist in $FTP_DIR"
fi

But I get the following error message printed on UNIX screen , which I want to get rid off. I think this error message appears owing to failure of ls command in COmmand-1 as stated above

Error message printed on screen is
KE*20080711*zip not found

CAn you please advice how to get rid of this messages to be printed on screen. Instaed can we move such errors to temp files

Regards
Suresh
  #2 (permalink)  
Old 07-11-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink Couple of things at work here.

First, there is the assignment of the filename variable.
Code:
> mfilename=$(ls z52075.*.zip)
> echo $mfilename
z52075.per.files.zip
> mfilename=$(ls z52075.*.zip2)
ls: cannot access z52075.*.zip2: No such file or directory
> mfilename=$(ls z52075.*.zip2 2>/dev/null)
> echo $mfilename

>
Above, the first set the filename which was found from the ls command. See my echo of the variable. I then try to set to a file I know the ls will not find - and you can see the unix error condition returned. Tried agin; and I added the error handling. Note my second echo returns nothing.

Second, you are checking for -f or ordinary file. Is a zip file ordinary? I think I would be doing a -s to see if the file has non-zero length.
  #3 (permalink)  
Old 07-12-2008
sureshg_sampat sureshg_sampat is offline
Registered User
  
 

Join Date: Nov 2006
Location: Czech Republic
Posts: 49
Error Handling -pls advice

Thanks for inputs,
Using -f , actually I am checking for presence of the zip file
If present , then only I proceed further
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0