How to distinguish between "command not found" and "command with no result"

system() call imeplemented in solaris is such a way that:
Command not found - return code 1
Command executed successfully without Output - return code 1
how to distinguish between these two based on return code in a c - file?
Can you help on this ?

System isn't supposed to behave that way. Can you post some code you are using exhibiting the issue ?

A simple c file:

#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
int main()
{
int exitcode;
char *buf="/var/tmp/bin/em_validation";
char *buf1="grep madhu x";
char *buf2="grep ding x";
char *buf3="ls";
char *buf4="ls > output";

exitcode=system((const char*)buf);
if ((exitcode != -1) && WIFEXITED(exitcode))
     exitcode = WEXITSTATUS(exitcode);
printf("\ncommand not found = %d\n",exitcode);

exitcode=system((const char*)buf1);
if ((exitcode != -1) && WIFEXITED(exitcode))
     exitcode = WEXITSTATUS(exitcode);
printf("\ngrep no output = %d\n",exitcode);

exitcode=system((const char*)buf2);
if ((exitcode != -1) && WIFEXITED(exitcode))
     exitcode = WEXITSTATUS(exitcode);
printf("\ngrep with output = %d\n",exitcode);

exitcode=system((const char*)buf3);
if ((exitcode != -1) && WIFEXITED(exitcode))
     exitcode = WEXITSTATUS(exitcode);
printf("\nsuccessful command ls  = %d\n",exitcode);

exitcode=system((const char*)buf4);
if ((exitcode != -1) && WIFEXITED(exitcode))
     exitcode = WEXITSTATUS(exitcode);
printf("\nsuccessful command with no output ls > outputfile  = %d\n",exitcode);



return exitcode;
}

file x contains:
ding

I have 127 as return status for the not found command and 0 for the successful with no output one.
What are your results ? What OS are you running

sati01> uname -a
SunOS sati01 5.10 Generic_137137-09 sun4u sparc SUNW,Sun-Fire-V240

On this I am getting Status =1 for command not found.
Getting the same result on 5.9 also.

Interesting. It looks like system return value meaning has changed between Solaris 10 and OpenSolaris (which I use):

On Solaris 10 (SunOS 5.10) system(3C) manual page:

RETURN VALUES
     The system() function executes vfork(2) to  create  a  child
     process that in turn invokes one of the exec family of func-
     tions (see exec(2)) on  the  shell  to  execute  string.  If
     vfork()  or the exec function fails, system() returns -1 and
     sets errno to indicate the error.

On OpenSolaris (SunOS 5.11):

RETURN VALUES
     The system() function executes posix_spawn(3C) to  create  a
     child  process  running  the shell that in turn executes the
     commands in string. If posix_spawn() fails, system() returns
     -1  and sets errno to indicate the error; otherwise the exit
     status of the shell is returned.

I'm afraid you'll have to use a different approach to distinguish these cases.