The UNIX and Linux Forums  


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
SYSOPEN FAIL in UNIX yeukai UNIX for Advanced & Expert Users 1 02-03-2008 07:17 PM
fail to telnet localhost 106 satimis Ubuntu 22 12-16-2007 10:54 PM
Fail to run init-script from crontab indo1144 UNIX for Advanced & Expert Users 5 09-14-2005 11:47 AM
cron fail to run kerwin_hsu UNIX for Advanced & Expert Users 6 03-11-2002 01:57 AM
Mail fail adela UNIX for Dummies Questions & Answers 3 06-29-2001 10:05 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 10-27-2008
er_zeeshan05 er_zeeshan05 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 29
fail a unix script

i am basically DWH professional.
I want to write a script such that whenver the file size is greather than 0 the script fails
  #2 (permalink)  
Old 10-27-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,434
man test
Code:
test -s file && exit
What DWH stand for
  #3 (permalink)  
Old 10-27-2008
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,240
data warehouse.

See also ETL - Extract Transform Load.
  #4 (permalink)  
Old 10-27-2008
er_zeeshan05 er_zeeshan05 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 29
hi
so above script will fail when file has size greater than 0 or it will search for existance of file
  #5 (permalink)  
Old 10-28-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 Looking at another way...

file11 will be empty, file12 will be non-blank

Code:
> touch file11
> echo "hello" >file12
> ls -l file11 file12
-rw-rw---- 1 xxx dp 0 Oct 28 05:41 file11
-rw-rw---- 1 xxx dp 6 Oct 28 05:42 file12

> if [ -s file11 ]; then echo "fail here, file bytes more than 0"; fi 

> if [ -s file12 ]; then echo "fail here, file bytes more than 0"; fi 
fail here, file bytes more than 0

>
  #6 (permalink)  
Old 10-28-2008
er_zeeshan05 er_zeeshan05 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 29
it useless

i dont think this reply helps nothing personal
i want the unix script to fail
i dont know know much i think unix has code like success code fail ode
i want fail code to come when file has record
any one god ideasa
  #7 (permalink)  
Old 10-28-2008
Ikon's Avatar
Ikon Ikon is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2008
Location: Phoenix, Arizona
Posts: 669
Code:
file=somefile
if [ ! -s $file ]
 then
  exit 1
 fi
will give exit code of 1 if file is greater than 0 bytes.


EDIT: Had to add the !

Last edited by Ikon; 10-28-2008 at 02:47 PM..
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 04:15 AM.


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