delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/12/11/07:27:22

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
From: "Luis Torres" <luis DOT torres AT igm DOT pt>
To: "Brian Ford" <ford AT vss DOT fsi DOT com>, "Luis Torres" <torres2003 AT sapo DOT pt>
Cc: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Date: Thu, 11 Dec 2003 11:41:47 +0000
In-Reply-To: <Pine.GSO.4.58.0312091635400.28297@eos>
MIME-Version: 1.0
Subject: Re: Different behaviour of "test -f" under cmd and bash, when called from compiled App
Message-ID: <HPQBLJ00.E5U@mail1.igm.pt>

Hi Brian,

Thans for the hint. I have not tested it out, but it suggested me a way to handle the problem, and 
was quite helpful. In fact the whole issue was because I wanted to get a Java application that relies
on Cygwin compiled code, symbolic links and shell scripts, to work [number 1)- you  stripped off ...].
That is Java provides the graphical interface but i/o is dealt with by Unix code.

In fact I discovered the commands test -f issued from a program compiled for Cygwin, while not working
under cmd.exe, caused no problem when the program was invoked from Java, so made no changes in
the code. What caused problems were the scripts and symbolic links: so if the scripts are compiled using
sch-3.2-tgz (from Rosales) into *.exe files and the symbolic links replaced by *.exe files things work.

There is a more complex construct in the code -  a program that dynamically pipes to and runs a script 
(which I compiled), which I on't now if it works. But for the stand alones it works fine.

Regards,

Luis

On Tue, 9 Dec 2003 16:40:24 -0600 (CST), Brian Ford wrote:

>On Tue, 9 Dec 2003, Luis Torres wrote:
>
>> 2)  In relation to the above I tracked the following problem. If I use (interactive shell):
>>       test -f AfileIKnowExists && echo YES (under either cmd.exe or Cygwin/bash), I get the correct answer
>>        (test.exe  from /cygdrive/c/cygwin/bin as per official distribution)
>>       while if I use the code bellow within a program.exe compiled under Cygwin, I get the correct answer if
>>          I use it within bash but NOT the correct answer if I use the program in cmd.exe
>>
>>      Code : "
>>           strcpy(command,"test -f ");
>>   strcat(command,fpath);
>>   if(verbose)
>>     fprintf(stderr,"Executing %s\n", command);
>>   if(!system(command))
>>
>I don't see the problem right off, but HTH.
>
>This will do:
>
>/bin/sh -c command
>
>Also, sh is ash.
>
>With  a  command argument, the result of `system' is the exit
>status returned by `/bin/sh'.
>
>-- 
>Brian Ford
>Senior Realtime Software Engineer
>VITAL - Visual Simulation Systems
>FlightSafety International
>Phone: 314-551-8460
>Fax:   314-551-8444
>





--
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