This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

system() fails on pristine Windows systems

Hi all,

I've been through the FAQ and 2 years worth of archives, trying every
trick I could find there, but I cannot make this work.  I have a program
which calls Cygwin's system() function.  It works reliably from the
Windows command line (outside of Cygwin) on machines that have Cygwin
installed, even though the Cygwin bin-related directories are not in the
path.  It works on every single Unix machine I've ever tried it on.  It
fails reliably with the error message "No such file or directory" only
on Windows machines which do not have Cygwin installed.

To test that I haven't hosed anything up, I wrote a little demonstration
program which illustrates the problem:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

main() {
  char foo[]="notepad";
  int ret;

  ret = system(foo);
  if (ret != 0) {
    fprintf(stderr,"Command failed: %s - %s\n",foo,strerror(errno));

If I build the exe file (with g++ - "g++ -o systest systest.cxx"), and
put both the exe file and cygwin1.dll on the non-Cygwin system, I get
the error (in this case, "Command failed: notepad.exe - No such file or
directory").  I've verified this behavior about 7 different Windows
machine with various flavors of Windows.

In addition, I've tried the various tricks - putting the directory
containing the exe file in the path (yes, before opening the cmd
window); putting cygwin1.dll in the \windows\system and
\windows\system32 directories; putting the Windows cmd.exe in the
directory with systest.exe; putting the Windows in the
directory with systest.exe; even putting the Cygwin sh.exe in that
directory.  I have even tried replacing the call to run notepad.exe with
calls to do internal commands like "path" and "set" in Windows.  No joy...

It seems obvious to me that system() is not finding a command
interpreter on the machine, although they are correctly listed in the
path for the command window.  Am I missing something really stupid that
needs to be included in the distribution or set in the program, or does
system() just not work the way I expect?

Thanks in advance...


-- Archie Warnock                       Internet:
-- A/WWW Enterprises          
--       As a matter of fact, I _do_ speak for my employer.

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]