06-04-2003
What you are calling a subshell isn't one and you seem to have parent and child mixed up.
If you write a command and call it "subshell". you can run it and get the exit code like this..
./subshell
exitcode=$?
And it doesn't matter that "subshell" is command that is also a shell script.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i downloaded a text file from metalab.unc.edu called sh.txt and in this reference manual it refers to shell scripting exit status .. at the end of one of the examples that author gave an exit status of 127..
to what does a 127 exit status refer too and what is its purpose in the code.
moxxx68 (1 Reply)
Discussion started by: moxxx68
1 Replies
2. Shell Programming and Scripting
How to capture output or numeric part given by $? command into the variable?
If I go for
var=`$?`
then $var is found empty. (2 Replies)
Discussion started by: videsh77
2 Replies
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
Hello,
I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue.
Can you please help me on this.
Thanks,
Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies
5. Shell Programming and Scripting
Hello,
I have a C++ binary that runs in my perl script. But, Currently, the binary is doing a core dump and i want to capture the retrun status of the binary to report as an issue.
Can you please help me on this.
Thanks,
Sateesh (1 Reply)
Discussion started by: kotasateesh
1 Replies
6. Shell Programming and Scripting
I'm preparing for exam and one of exams is to write own test command...
I wonder if in unix is a command which just returns exit code you specify..
I know I can easily write a function like this:
exStatus() {
return $1
}
-> my question is rather theoretical
thank you! (9 Replies)
Discussion started by: MartyIX
9 Replies
7. Programming
If I have a "Hello World" function (just prints that) and a similar "Goodbye World" function... is there a way (maybe a compiler option?) that I can get them to be executed directly as the absolute first and last things run in every function call.
So for example, the following code:
int foo()... (5 Replies)
Discussion started by: jjinno
5 Replies
8. Shell Programming and Scripting
Hi All,
I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script.
Is there a way I can capture the exit status of each individual child script after the execution is completed. (2 Replies)
Discussion started by: paragkalra
2 Replies
9. Shell Programming and Scripting
I have a shell script (#!/bin/sh) that interacts with Appworx and Banner Admin. In my script I want to check the exit status of awrun before continuing. awrun can run for 10 seconds or it can run for over a minute. So my question is, will it go through my if statement before awrun may even be... (2 Replies)
Discussion started by: smkremer
2 Replies
10. Shell Programming and Scripting
Hi All,
I am trying to create a zip file with all the txt files(these are in large number) in the current directory. I am able to do this operation sucessfully.
After this i want to get the status of the tar command executed and do accordingly. When i am trying with the below code, the status... (3 Replies)
Discussion started by: paddu
3 Replies
LEARN ABOUT OPENSOLARIS
hatimerun
hatimerun(1M) System Administration Commands hatimerun(1M)
NAME
hatimerun - run child program under a timeout
SYNOPSIS
/usr/cluster/bin/hatimerun -t timeOutSecs [-av] [-e exitcode]
prog args
/usr/cluster/bin/hatimerun -t timeOutSecs [-v] [-e exitcode]
[-k signalname] prog args
DESCRIPTION
The hatimerun utility provides a convenient facility for timing out the execution of another child, program. It is useful when programming
in scripting languages, such as the Bourne shell. See sh(1).
The hatimerun utility runs the program prog with arguments args as a child subprocess under a timeout, and as its own process group. The
timeout is specified in seconds, by the -t timeOutSecs option. If the timeout expires, then hatimerun kills the child subprocess's process
group with a SIGKILL signal, and then exits with exit code 99.
You can run this command in the global zone or in a non-global zone. The command affects only the global or non-global zone in which you
issue the command.
OPTIONS
The following options are supported:
-a Changes the meaning of hatimerun radically: instead of killing the child when the timeout expires, the hatimerun utility sim-
ply exits, with exit code 99, leaving the child to run asynchronously.
It is illegal to supply both the -a option and the -k option.
-e Changes the exit code for the timeout case to some other value than 99.
-k Specifies what signal is used to kill the child process group. The possible signal names are the same as those recognized by
the kill(1) command. In particular, the signal name should be one of the symbolic names defined in the <signal.h> descrip-
tion. The signal name is recognized in a case-independent fashion, without the SIG prefix. It is also legal to supply a
numeric argument to the -k option, in which case that signal number is used.
It is illegal to supply both the -a option and the -k option.
-t Specifies the timeout period, in seconds.
-v Verbose output, on stderr.
EXIT STATUS
If the timeout occurs, then hatimerun exits with exit code 99 (which can be overridden to some other value using the -e option).
If the timeout does not occur but some other error is detected by the hatimerun utility (as opposed to the error being detected by the
child program), then hatimerunhatimerun exits with exit code 98.
Otherwise, hatimerun exits with the child's exit status.
The hatimerun utility catches the signal SIGTERM. It responds to the signal by killing the child as if a timeout had occurred, and then
exiting with exit code 98.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscu |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
SEE ALSO
kill(1), sh(1), attributes(5)
Sun Cluster 3.2 10 Apr 2006 hatimerun(1M)