Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Finding return code for completed process ?? Post 302754731 by hergp on Friday 11th of January 2013 03:31:59 AM
Old 01-11-2013
If you are on Solaris, you could use dtrace for this. Create a file exit.d as

Code:
#!/usr/sbin/dtrace -s

syscall::rexit:
/execname == "ls"/
{
    printf ("ls exited with exitcode %d\n", arg0);
}

This example catches the exit code of the ls command. When you run the script, you get some output like:

Code:
dtrace: script './exit.d' matched 2 probes
CPU     ID                    FUNCTION:NAME
  7 105722                      rexit:entry ls exited with exitcode 0
  3 105722                      rexit:entry ls exited with exitcode 2
  1 105722                      rexit:entry ls exited with exitcode 0

The script will run, until you stop it with Ctrl-C.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

background process return code

Hi I have the following piece of code that is calling another child process archive.ksh in the background while read file; do file_name=`ls $file`; ksh archive.ksh $file_name &; done < $indirect_file The problem is, indirect_file may contain anwhere from 2 to 20 different... (5 Replies)
Discussion started by: Vikas Sood
5 Replies

2. UNIX for Advanced & Expert Users

return code of a process

two programs A and B writting in c++ I am using A to B and I want to know the return code of B. in B ------------------------ int main() { return 11; } ------------------------ in A ------------------------ int main() { system(A); } ------------------------ Is it the right way... (1 Reply)
Discussion started by: filedeliver
1 Replies

3. Programming

return code of a process

two programs A and B writting in c++ I am using A to B and I want to know the return code of B. in B ------------------------ int main() { return 11; } ------------------------ in A ------------------------ int main() { system(A); } ------------------------ Is it the right way... (1 Reply)
Discussion started by: filedeliver
1 Replies

4. Programming

getting the return code of forked child process (ftp)

Hi, From within my C++ program, I fork a child process and execl an ftp session (solaris), like this : std::string szStartCmd = "ftp -i -n -v 192.168.149.31"; int nExecRes = execl("/bin/sh", "sh", "-c", szStartCmd.c_str(), (char *)0); I use 2 pipes to communicate between my... (7 Replies)
Discussion started by: KittyJ
7 Replies

5. Shell Programming and Scripting

Return code of background process

Hi, I have a process that I run in the background that looks like this ${BASEDIR}/ksh/sqler.ksh ${compnames003} & and I would like to get the return code of the sqler.ksh script. so my code is like this ${BASEDIR}/ksh/sqler.ksh ${compnames003} & retcode=$? (3 Replies)
Discussion started by: c19h28O2
3 Replies

6. AIX

aix 4.2: finding out the return code of a savevg/mksysb ?

Am I right to assume that to check the return code of a savevg/mksysb on an AIX 4.2 is with the "$?" ? (1 Reply)
Discussion started by: Browser_ice
1 Replies

7. Shell Programming and Scripting

return code of multiple java process

Hi, I have a unix shell script which is launching multiple java processes by calling a java class in a loop, but each time with a different set of parameters. Now I have to use the return code from each process in the script later. but how do i obtain the return code from each process... (1 Reply)
Discussion started by: rama354
1 Replies

8. Shell Programming and Scripting

Background process, return code and pid.

Hey all, Okay, this one is tricky and I'm not sure there is a niec way to do it, or indeed anyway to do it. The main issue revolves around timing out a hung ssh. I am doing this by creating a wrapper script for the ssh with the following requirements. My requirements are: Defineable... (5 Replies)
Discussion started by: RECrerar
5 Replies

9. Shell Programming and Scripting

Process only files which have completed in transaction

Hi , I have a situation where I have to Process files ( move , edit or rename ) in a folder ..... This folder is a FTP folder and Files keep coming in when they are available ... So I should perform my actions on those which which completed transaction .. . Is there a way to identify a... (3 Replies)
Discussion started by: chillblue
3 Replies

10. Shell Programming and Scripting

Capturing the return code from background process

Hi All, I was out not working on unix from quite sometime and came back recently. I would really appreciate a help on one of the issue I am facing.... I am trying to kick off the CodeNameProcess.sh in PARALLEL for all the available codes. The script runs fine in parallel. Let say there are... (1 Reply)
Discussion started by: rkumar28
1 Replies
PEGASUS-EXITCODE(1)													       PEGASUS-EXITCODE(1)

NAME
pegasus-exitcode - Checks the stdout/stderr files of a workflow job for any indication that an error occurred in the job. This script is intended to be invoked automatically by DAGMan as the POST script of a job. SYNOPSIS
pegasus-exitcode [-h][-t n][-r rv][-n] job.out DESCRIPTION
pegasus-exitcode is a utility that examines the STDOUT of a job to determine if the job failed, and renames the STDOUT and STDERR files of a job to preserve them in case the job is retried. Pegasus uses pegasus-exitcode as the DAGMan postscript for all jobs submitted via Globus GRAM. This tool exists as a workaround to a known problem with Globus where the exitcodes of GRAM jobs are not returned. This is a problem because Pegasus uses the exitcode of a job to determine if the job failed or not. In order to get around the exitcode problem, Pegasus wraps all GRAM jobs with Kickstart, which records the exitcode of the job in an XML invocation record, which it writes to the job's STDOUT. The STDOUT is transferred from the execution host back to the submit host when the job terminates. After the job terminates, DAGMan runs the job's postscript, which Pegasus sets to be pegasus-exitcode. pegasus-exitcode looks at the invocation record generated by kickstart to see if the job succeeded or failed. If the invocation record indicates a failure, then pegasus-exitcode returns a non-zero result, which indicates to DAGMan that the job has failed. If the invocation record indicates that the job succeeded, then pegasus-exitcode returns 0, which tells DAGMan that the job succeeded. pegasus-exitcode performs several checks to determine whether a job failed or not. These checks include: 1. Is STDOUT empty? If it is empty, then the job failed. 2. Are there any <status> tags with a non-zero value? If there are, then the job failed. Note that, if this is a clustered job, there could be multiple <status> tags, one for each task. If any of them are non-zero, then the job failed. 3. Is there at least one <status> tag with a zero value? There must be at least one successful invocation or the job has failed. In addition, pegasus-exitcode allows the caller to specify the exitcode returned by Condor using the --return argument. This can be passed to pegasus-exitcode in a DAGMan post script by using the $RETURN variable. If this value is non-zero, then pegasus-exitcode returns a non-zero result before performing any other checks. For GRAM jobs, the value of $RETURN will always be 0 regardless of whether the job failed or not. Also, pegasus-exitcode allows the caller to specify the number of successful tasks it should see using the --tasks argument. If pegasus-exitcode does not see N successful tasks, where N is set by --tasks, then it will return a non-zero result. The default value is 1. This can be used to detect failures in clustered jobs where, for any number of reasons, invocation records do not get generated for all the tasks in the clustered job. In addition to checking the success/failure of a job, pegasus-exitcode also renames the STDOUT and STDERR files of the job so that if the job is retried, the STDOUT and STDERR of the previous run are not lost. It does this by appending a sequence number to the end of the files. For example, if the STDOUT file is called "job.out", then the first time the job is run pegasus-exitcode will rename the file "job.out.000". If the job is run again, then pegasus-exitcode sees that "job.out.000" already exists and renames the file "job.out.001". It will continue to rename the file by incrementing the sequence number every time the job is executed. OPTIONS
-h, --help Prints a usage summary with all the available command-line options. -t n, --tasks n Number of tasks expected. If less than n tasks succeeded, then pegasus-exitcode will fail with a non-zero return value. This is used in cases where we may not get a Kickstart invocation record for some tasks. Normally Seqexec will detect failed Kickstart invocations and fail accordingly. -r rv, --return rv Return value reported by DAGMan. This can be specified in the DAG using the $RETURN variable. If this is non-zero, then pegasus-exitcode immediately fails with a non-zero return value itself. -n, --no-rename Don't rename job.out and job.err to .out.XXX and .err.XXX. This option is used primarily for testing. AUTHORS
Gideon Juve <juve@usc.edu> Pegasus Team http://pegasus.isi.edu 05/24/2012 PEGASUS-EXITCODE(1)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy