Sponsored Content
Top Forums Shell Programming and Scripting Check the exit status in a pipe call Post 302561957 by Rkolbe on Wednesday 5th of October 2011 03:20:44 PM
Old 10-05-2011
Check the exit status in a pipe call

Guys, I have a problem Smilie 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:
Code:
gzip -dc <file> | app

The problem is: How can I check if there is any problem in the gzip (exit status) from my app?

Thanks !

Last edited by Franklin52; 10-06-2011 at 03:18 AM.. Reason: Please use code tags, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check the status and send an email with status

Hi, We have a text file which has the following data. ISA~00~ ~00~ ~ZZ~VISTN ~ZZ~U1CAD ~051227~183 7~U~00200~000011258~0~P~< GS~FA~EE05J~U1CAD~051227~1831~000011258~X~002002 ST~997~0001 AK1~SH~247 AK2~856~2470001 AK5~A AK2~856~2470002 AK5~A... (3 Replies)
Discussion started by: isingh786
3 Replies

2. UNIX for Dummies Questions & Answers

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 { (1 Reply)
Discussion started by: epall
1 Replies

3. UNIX for Dummies Questions & Answers

exit status of command in a pipe line

Hi, I am trying to test the exit status of the cleartool lsvtree statement below, but it doesn't seem to be working due to the tail pipe, which it is testing instead. Is there a way around this without adding a tonne of new code? cleartool lsvtree $testlocation/$exe_name | tail -15 ... (10 Replies)
Discussion started by: topcat8
10 Replies

4. 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

5. Shell Programming and Scripting

How to get the exit status

Hi all, I'm running a program which return 1 upon success. But when encounters problem shell return 's '1' . How to differentiate between them the shell return value and script return value. Ex. function fn return '1' if executed successfully and '0' if failed. But when if shell encounters... (1 Reply)
Discussion started by: yhacks
1 Replies

6. 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

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 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

9. 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

10. Shell Programming and Scripting

Check file if not found send mail if exit call second script

I need to check my script and change to working mode. currently it was not sending the mail and exit without calling the second script. I need to check the file is present ="/home/Rvtools/test.csv" if this file not found after the time retry send mail file not found If the file exit run the... (2 Replies)
Discussion started by: ranjancom2000
2 Replies
popen(3S)																 popen(3S)

NAME
popen(), pclose() - initiate pipe I/O to/from a process SYNOPSIS
DESCRIPTION
creates a pipe between the calling program and a command to be executed by the POSIX shell, (see sh-posix(1)). The arguments to are pointers to null-terminated strings containing, respectively, a shell command line and an I/O mode, either for reading or for writing. returns a stream pointer such that one can write to the standard input of the command if the I/O mode is by writing to the file stream; and one can read from the standard output of the command if the I/O mode is by reading from the file stream. Because open files are shared, a type command can be used as an input filter and a type command as an output filter. If mode is other than or the result is undefined. A stream opened by should be closed by which waits for the associated process to terminate and returns the exit status of the command. However, if a call caused the termination status to be unavailable to then returns -1 with errno set to This can happen in one of the fol- lowing conditions: o If the signal handler for is set to o If the signal handler or another thread in the same process issues or call. APPLICATION USAGE
After a stream is associated with a pipe by the stream is byte-oriented (see orientation(5)). RETURN VALUE
Upon successful completion, returns a pointer to an open stream that can be used to read or write to the pipe. Otherwise, it returns a NULL pointer if files or processes cannot be created and set errno to indicate the error. The success of the command execution can be checked by examining the return value of Upon successful return, returns the termination status of the command language interpreter. Otherwise, returns -1 if stream is not associ- ated with a command and set errno to indicate the error. ERRORS
The function fails if: The maximum number of file descriptors allowed are currently open. The function fails if: The status of the child process is not available. WARNINGS
If the original and processes concurrently read or write a common file, neither should use buffered I/O because the buffering will not work properly. Problems with an output filter can be forestalled by careful buffer flushing, e.g., with see fclose(3S). SEE ALSO
pipe(2), wait(2), fclose(3S), fopen(3S), system(3S), orientation(5), thread_safety(5). STANDARDS CONFORMANCE
popen(3S)
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy