Return Value
Hi Guys,
I wanted to track the return value of certain errors in the linux process. How can i get the error numbers. I wrote a script which takes database dumps and process with sqlldr and procedure. In this case dumps exported successfully, but loader failed due to insufficient space. So i need to check the return value of insufficient space for each process and proceed. The script should stop process to proceed further in case of only insufficient failure. |
hello,
$? will normally give you the exit code in bash in a script you would.. ./run script (or command) echo $? OR EXITSTATUS=$?;echo ${EXITSTATUS} As long as the script or command does create the correct exit codes...sometimes you might find a command or script doesn't support them. Generally an error/failure would produce an exit code of 1 and success is generally exit code of 0. If you have error checking in your scripts and you execute other scripts of your own and want to provide error exit codes for your own scripts, then you can when exiting a script do it with... exit 0 #script completed successfullly OR exit 1 #script failure Generally i use them in my own scripts when required, i run checks on whatever the script is supposed to have done successfully and then depending on those checks i then exit the script with status codes of 1 or 0 hope this helps, regards ps- without seeing the script and the commands its hard to say more than this |
So, you want to stop a script when the disk is full, is that what you want?
What about putting something like that in your script: Quote:
|
I'm intrigued now...more often lately (twice in the last two days) have i suddenly come across this %%% with variables. Can you point me in a direction of a sufficient doc for this...
I looked and found it does some kind of substitution type of thing...removing values from the variable and stuff ...as you can tell i don't really have a clue what it does :) |
Actually, %% trims on the right.
let's consider this variable: Quote:
Quote:
Easy: I do exactly the same thing, but instead of removing %, I remove a space and anything that's after it (in regular expression, it means " *": Quote:
Fortunatelly, I have another trick: the % is the same as %%, but matches the smallest possible match: Quote:
But what if I want to remove the first word? Well, there is another trick: the '#' is exactly like '%' (and '##' is like %%) but on the left: Quote:
|
Ah cheers, after having a little go myself i get it now thanks...
%%[expression to match to remove everything from first match to end of contents of variable]* ##[go the opposite way]* %%[t] means remove the last character if it matches t well you may not understand what i wrote hear but the main thing is i get it :) Thanks |
All times are GMT -5. The time now is 03:02 PM. |