how to check exit status in awk script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to check exit status in awk script
# 1  
Old 06-24-2006
Java how to check exit status in awk script

Hi,

I have a main program which have below lines

-
awk -f test.awk inputFileName
-
I wonder how to check status return from awk script.



content of awk script:
test.awk
---
if ( pass validation )
{
exit 1
}
else
{
exit 0
}
# 2  
Old 06-24-2006
the awk man page says that for exit <value> - value is returned to the shell and must be a value from 0 - 255

Code:
awk -f test.awk inputFileName
if [ $? -eq 0 ] ; then
    echo "Pass"
else
    echo "Fail"
fi

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exit status in the script

Hi all, I am trying to use a script (a.sh) which is calling another script(b.sh). And I want to use the exit code(set by me) of b.sh in a.sh. I am using this in b.sh #!/bin/sh <-- code --> if ; then exit 0 else exit 1 fiBut... (2 Replies)
Discussion started by: Raj999
2 Replies

2. Shell Programming and Scripting

Check/get the exit status of a remote command executed on remote host through script

Geeks, Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s). Here's the complete... (5 Replies)
Discussion started by: lovesaikrishna
5 Replies

3. Shell Programming and Scripting

exit status from the script is always 0

Hi , I have a bash script , which does the network configuration. Messages from this script are dumped on console as well as stored in a log file . This script is invoked from a C code using system call . The script returns different exit code , to indicate different error cases. The... (1 Reply)
Discussion started by: abhirai
1 Replies

4. Shell Programming and Scripting

awk with exit status if pattern not found

Hi everyone, Looking at writing another awk program here to find a pattern on a text file. If patterns aren't found I want the awk program to exit and then bash to file a failure log on the local machine. Then later a management framework we have in place will read if that failure log file... (3 Replies)
Discussion started by: Zaphod_B
3 Replies

5. Shell Programming and Scripting

Check the exit status in a pipe call

Guys, I have a problem :confused: and I need some help: I've to process many huge zip files. I'd code an application that receive the data from a pipe, so I can simple unzip the data and send it (via pipe) to my app. Something like that: gzip -dc <file> | app The problem is: How can I... (7 Replies)
Discussion started by: Rkolbe
7 Replies

6. Shell Programming and Scripting

How to check exit status of unset variables

Hi All, Is there any way to check exit status of unset variables? In the following code PathX is not set and the script terminates without checking exit status. #!/bin/bash Path="/tmp/log" cd ${PathX:?} if ;then echo "Exit Status : non zero" else echo "Exit Status :... (2 Replies)
Discussion started by: sussus2326
2 Replies

7. Shell Programming and Scripting

Check for exit status

Hi I have following code I want If whole code executes successfully then return true If found any error then print the error I tried if ; then But this checks only for the just upper line execution #!/bin/bash PATH1=/var/log/mysql PATH2=/home/ankur/log FILE1=mysql-bin.index... (4 Replies)
Discussion started by: kaushik02018
4 Replies

8. Shell Programming and Scripting

How to print exit status in AWK

Hi all, How can I print the exit status in AWK? echo $? doesnt work for me Thanks (4 Replies)
Discussion started by: Pauline mugisha
4 Replies

9. Shell Programming and Scripting

check exit status of bg scripts

HI All, I am running one shell script, in that script i am calling 4 scripts in the background. abc.ksh & efg.ksh & xky.ksh & mno.ksh & please let me know, how could i find the success and failure of each script. i Cannot use $?, because i want to run all the scripts in parellel. ... (2 Replies)
Discussion started by: javeed7
2 Replies

10. Shell Programming and Scripting

check exit status - Expect Script

from my main script, i am calling an expect script. there are a lot of conditions in the Expect script and it can have any exit value based on success or failure of the Expect Script. how can i check the exit status of Expect scritp in the main script. (1 Reply)
Discussion started by: iamcool
1 Replies
Login or Register to Ask a Question