Q1) What do I do if I don't want that Status Code = 0 to be displayed at the terminal. I tried >/dev/null. But when I use this, the $id doesn't get variable assigned to it.
Q2) At the same time, how do I check the returned values and know whether the dsjob command was successful or failed + where can I find list of returned values (I looked at the documentation and wasn't able to find it) .
Add -jobstatus to your command line so you get more information on the status of the job. Look in $DSHOME/include/dsapi.h for the error codes to check for:
/* 'jobStatus' values... */
#define DSJS_RUNNING 0 /* Job running */
#define DSJS_RUNOK 1 /* Job finished a normal run with no warnings */
#define DSJS_RUNWARN 2 /* Job finished a normal run with warnings */
#define DSJS_RUNFAILED 3 /* Job finished a normal run with a fatal error */
#define DSJS_VALOK 11 /* Job finished a validation run with no warnings */
#define DSJS_VALWARN 12 /* Job finished a validation run with warnings */
#define DSJS_VALFAILED 13 /* Job failed a validation run */
#define DSJS_RESET 21 /* Job finished a reset run */
#define DSJS_CRASHED 96 /* Job was stopped by some indeterminate action */
#define DSJS_STOPPED 97 /* Job was stopped by operator intervention (can't tell run type) */
#define DSJS_NOTRUNNABLE 98 /* Job has not been compiled */
#define DSJS_NOTRUNNING 99 /* Any other status */
And you don't need to capture and cut out that status that is echo'd to the screen, simply assign the status of the command itself (just like any other UNIX function) to a variable using $? and check that - or check it directly.
-craig
"You can never have too many knives" -- Logan Nine Fingers
a) I wanted to suppress both from displaying to the output, looks like as mentioned by ArndW 2>&1 should take care about it.
b) I want to assign Newest Id to variable $Id
c) Based on the Status Code, I wanted to know if the above command has worked successfully. I don't want to check job status as I do that prior to calling the above command line.
The 0 (ie) the status code comes along with event id (841). I can do a grep to ignore the status code. But wanted to have value of event id in the variable + use the status code to verify if the command has worked properly (I already check status of the job before executing this command).
Should I not deal with the status code. I mean if in case the command didnt execute properly for some reason (I do check the job status before running this command). Then what shall I check against?
Should I not deal with the status code. I mean if in case the command didnt execute properly for some reason (I do check the job status before running this command). Then what shall I check against?
I tried to look in $DSHOME/include/dsapi.h. But didn't know how to look at the returned code from dsjob -lognewest. Similarly I want to look for dsjob -logdetail etc..
You wont find the return code from any *.h file. Its standard unix command return code that the OS returns.
For examply, if I run a grep command, i will get a status code. 0 means all went well and the grep was successful in finding a string/character. 1 means no matches found. 2 means there were syntax errors. You can get this info by googling for "grep man".
Similarly different commands have different exit codes.
As I mentioned earlier, 0 usually means the command executed succesfully.
$? holds the exit status of the last executed command.
so for your command I would do something like