X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: iunknown2k4 AT yahoo DOT co DOT in (anonymous) Newsgroups: comp.os.msdos.djgpp Subject: Problem using system( ) Date: 18 Sep 2004 03:01:51 -0700 Organization: http://groups.google.com Lines: 41 Message-ID: NNTP-Posting-Host: 202.9.150.199 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1095501711 30583 127.0.0.1 (18 Sep 2004 10:01:51 GMT) X-Complaints-To: groups-abuse AT google DOT com NNTP-Posting-Date: Sat, 18 Sep 2004 10:01:51 +0000 (UTC) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I read the documentation for the system() function and I could understand that if the COMMAND.COM is used then it will always return 0, even if the command did not execute. I want to know whether the command passed to the system() was successfully run or not. I am not able to understand the following: "The behavior of `system' can be customized at run time by defining the variable `DJSYSFLAGS' in the environment. The value of that variable should be the numerical value of `__system_flags' that you'd like to set; it will override the value of `__system_flags' specified when the program was compiled." Does it mean that the `DJSYSFLAGS' should be defined something like #define DJSYSFLAGS ( __system_emulate_command | __system_use_shell \ |__system_call_cmdproc) Also the return value is in the lower 8 bits, so I'm checking it like struct retVal { char r[2]; }*ret; ... int temp = system(cmd); ret = (struct retVal *) &temp; printf ("\n %d %d", ret->r[0], ret->r[1]); .... But, the vales are always zero even for system() called with an invalid command. Am I doing something wrong? Please help.