If command/program has done correctly for *nix systems, it return 0 if okay and not 0 if there is some error. Usually command doc include comments for every exit codes.
Variable ? include last command exit status.
So test mysql command with correct values and not so correct values.
After command check exit status
I have a script which loads data files into Oracle and then moves each file into a 'processed' directory when each file has finished loading.
Last night I found that the script was failing on the mv statement (with a return code 2) and the following message,
mv: cannot access... (1 Reply)
Hi,
I am using /bin/sh. I want to display the stdout and stderr on the terminal as well as save it in a file, so I'm using this command.
gmake all 2>&1 | tee log
But even if gmake fails, it's always giving 0 as exit status, i suppose because of tee.
# false 2>&1 | tee Log
# echo $?
0... (2 Replies)
Hello friends,
Kindly help me in developing a script that asks user to enter a value and will wait for 5 seconds for the feedback. If there is no answer from the user the script will perform exit or it will continue doing something else
Ex: If yu have a multi OS system i believe while... (3 Replies)
Hi All,
I have developed below script for FTP a file from unix machine to another machine.
ftpToABC ()
{
USER='xyz'
PASSWD='abc'
echo "open xx.yy.zbx.aaa
user $USER $PASSWD
binary
echo "put $1 abc.txt" >> /home/tmp/ftp.$$
echo "quit" >> /home/tmp/ftp.$$
ftp -ivn <... (3 Replies)
Hello All
My req is to store the exit status of a command in shell variable
I want to check whether the file has header or not
The header will contain the string
DATA_ACQ_CYC_CNTL_ID
So I am running the command
head -1 $i | grep DATA_ACQ_CYC_CNTL_ID
Now I have to check if... (6 Replies)
Hi ,
I have following code in my shell script :
"$TS_BIN/tranfrmr" "${TS_SETTINGS}/tranfrmr_p1.stx" "${TS_LOGS}/tranfrmr_p1.err" | (
"$TS_BIN/cusparse" "${TS_SETTINGS}/cusparse_p2.stx" "${TS_LOGS}/cusparse_p2.err" | (
"$TS_BIN/tsqsort" "${TS_SETTINGS}/srtforpm_p3.stx"... (8 Replies)
Hi,
I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script.
My intension is to execute... (4 Replies)
Hi All,
I am using below snippet to search for a string (read from a file 'searchstring.out') in all locations (/) and then iterate over the files found to write the locations and the respective owner to an output file.
However, this doesn't work as I believe the find command doesn't exit's... (11 Replies)
Hi,
i am new here let me say HI for all.
now i have a question please:
i am sending one command to my machine to create 3 names.
if one of the names exists then the box return error message that already have the name but will continue to create the rests.
How i can break the command and... (7 Replies)
Discussion started by: Amiri
7 Replies
LEARN ABOUT PLAN9
wait.h
wait.h(3HEAD) Headers wait.h(3HEAD)NAME
wait.h, wait - wait status
SYNOPSIS
#include <sys/wait.h>
DESCRIPTION
When a process waits for status from its children using either the wait(3C) or waitpid(3C) function, the status returned can be evaluated
with the following macros, defined in <sys/wait.h>. These macros evaluate to integral expressions. The stat argument to these macros is the
integer value returned from wait() or waitpid().
WCOREDUMP(stat) If the value of WIFSIGNALED (stat) is non-zero, this macro evaluates to a non-zero value if a core image of
the terminated child was created.
WEXITSTATUS(stat) If the value of WIFEXITED(stat) is non-zero, this macro evaluates to the exit code that the child process
passed to _exit() (see exit(2)) or exit(3C), or the value that the child process returned from main.
WIFCONTINUED(stat) Evaluates to a non-zero value if status was returned for a child process that has continued.
WIFEXITED(stat) Evaluates to a non-zero value if status was returned for a child process that terminated normally.
WIFSIGNALED(stat) Evaluates to a non-zero value if status was returned for a child process that terminated due to the receipt
of a signal.
WIFSTOPPED(stat) Evaluates to a non-zero value if status was returned for a child process that is currently stopped.
WSTOPSIG(stat) If the value of WIFSTOPPED(stat) is non-zero, this macro evaluates to the number of the signal that caused
the child process to stop.
WTERMSIG(stat) If the value of WIFSIGNALED(stat) is non-zero, this macro evaluates to the number of the signal that
caused the termination of the child process.
The <sys/wait.h> header defines the symbolic constants listed below for use with waitpid(3C).
WNOHANG Do not hang if no status is available; return immediately.
WUNTRACED Report status of stopped child process.
The symbolic constants listed below are defined as possible values for the options argument to waitid(2).
WEXITED Wait for processes that have exited.
WSTOPPED Status is returned for any child that has stopped upon receipt of a signal.
WCONTINUED Status is returned for any child that was stopped and has been continued.
WNOHANG Return immediately if there are no children to wait for.
WNOWAIT Keep the process whose status is returned in infop in a waitable state.
The type idtype_t is defined as an enumeration type whose possible values include the following:
P_ALL
P_PID
P_PGID
The id_t and pid_t types are defined as described in <sys/types.h>.
The siginfo_t type is defined as described in <signal.h>.
The rusage structure is defined as described in <sys/resource.h>.
Inclusion of the <sys/wait.h> header can also make visible all symbols from <signal.h> and <sys/resource.h>.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO exit(2), waitid(2), exit(3C), wait(3C), waitpid(3C),attributes(5), standards(5)SunOS 5.10 10 Sep 2004 wait.h(3HEAD)