fail a unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fail a unix script
# 1  
Old 10-27-2008
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  
Old 10-27-2008
man test
Code:
test -s file && exit

What DWH stand for Smilie
# 3  
Old 10-27-2008
data warehouse.

See also ETL - Extract Transform Load.
# 4  
Old 10-27-2008
hi
so above script will fail when file has size greater than 0 or it will search for existance of file
# 5  
Old 10-28-2008
Hammer & Screwdriver 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  
Old 10-28-2008
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  
Old 10-28-2008
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 03:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fail Parent Script if any of the child fails

I have requirement where I need to fail parent if any one of the child process fails. Here is the code snippet for i in 1 2 3 4 5 6 7 8 9 10 do child_script $i & done wait I need to fail my main script if any one of my child process fails (8 Replies)
Discussion started by: gvkumar25
8 Replies

2. Shell Programming and Scripting

Need help to write to log file whether the shell script call pass fail

I have the below script triggered daily at 330am in the morning, since last 7 days job not writing anything to database. below impala shell calling shell file which has sql , it is extracting data and loads to a flat file txt file. which is going wrong for last 1 week. need help, echo... (2 Replies)
Discussion started by: cplusplus1
2 Replies

3. HP-UX

[HP UNIX B.10.20] NFS Client SubSystem fail

Recently moved a HP Unix B.10.20 system from US to Thailand, and everything is work well in US but after we changed: 1. set_parms ip_address (change the IP to TH range) 2. set_parms addl_netwrk (change the Subnet, Gateway, Domain name, DNS Svr Name, and DNS IP) 3. vi /etc/hosts (to commented... (4 Replies)
Discussion started by: beta911
4 Replies

4. Shell Programming and Scripting

sed commands success / fail from commandline vs ksh script

solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200 I need a sed command that tests true when presented with lines that contain either forward and backslash. input file: c:/myFile.txt c:\yourFile.txt It doesn't appear that sed (in my environment anyway) supports... (4 Replies)
Discussion started by: msutfin
4 Replies

5. Shell Programming and Scripting

Banner causes scp to fail from script but not command line.

Hi, We have an interesting issue which is similar to the one in this thread, but that never provided a full answer. - Ohh apparently I can't post URLs till I have 5 posts, sorry. We have a simple script that copies files from one shelf to the other. Both shelves have an ssh banner defined. ... (3 Replies)
Discussion started by: RECrerar
3 Replies

6. Shell Programming and Scripting

A simple script fail

Hi, I am a programming newbie, I have started learning C++ a couple of months ago. Unfortunately I don't have too much time in my hands to learn it properly. I need to write a simple script for a project I am doing but I am failing quite hard :mad: (the fact that I am learning C++ is completely... (3 Replies)
Discussion started by: Akhlore
3 Replies

7. Shell Programming and Scripting

tr command fail to work in script

Hi, I has the following command in the script. This command works fine if I execute on command prompt. If I run the script, this is not working as expected (deleting CR). tr -d "\015" < ${FilePath}/${FileName} > ${FilePath}/${File_Prefix}.csv I could not figure out whats... (6 Replies)
Discussion started by: kavuri
6 Replies

8. Shell Programming and Scripting

The same script with extra variables seems to fail

Hey everyone, I have a problem with a certain shellscript. I have a script like this: #!/bin/sh template=$1 for values in {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}; do set $values X=$1; Y=$2; Z=$3; M=$4 mkdir "X$X-Y$Y-Z$Z-M$M" cp... (2 Replies)
Discussion started by: mario8eren
2 Replies

9. UNIX for Advanced & Expert Users

SYSOPEN FAIL in UNIX

Hi guys can someone please assist me, I'm running my Accountin package on UNIX and when I try to run the programs/modules I get an error message "SYSOPEN FAILED. Anybody with an idea what this means? (1 Reply)
Discussion started by: yeukai
1 Replies

10. UNIX for Advanced & Expert Users

Fail to run init-script from crontab

I have written a "simple" shell-script (BASH) to monitor the logs of our Resin-applicationserver. Whenever Resin runs out of available heap-space, the script then tries to restart the Resin-server. My problem is that my "autopilot"-script fails when it's run from crontab. Here's what the... (5 Replies)
Discussion started by: indo1144
5 Replies
Login or Register to Ask a Question