delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/04/25/17:10:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <426D5CAB.2070804@awcubed.com>
Date: Mon, 25 Apr 2005 17:10:03 -0400
From: Archie Warnock <warnock AT awcubed DOT com>
Organization: A/WWW Enterprises
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: system() fails on pristine Windows systems
X-IsSubscribed: yes

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>

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

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

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 command.com 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

-- Archie Warnock                       Internet: warnock AT awcubed DOT com
-- A/WWW Enterprises                    http://www.awcubed.com
--       As a matter of fact, I _do_ speak for my employer.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019