This is the mail archive of the cygwin@cygwin.com 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]

RE: system() not working as expected...




> -----Original Message-----
> From: cygwin-owner@sources.redhat.com
> [mailto:cygwin-owner@sources.redhat.com]On Behalf Of Brian Michael
> Genisio
> Sent: Thursday, June 28, 2001 4:54 PM
> To: cygwin@sources.redhat.com
> Subject: system() not working as expected...
>
>
> Hello, I am having the following problem... I am trying to port a
> program that
> uses the system call.  It works fine if I call it from the cygwin
> environment's
> bash shell, but if I just run bash.exe from a dos prompt, and run
> the program,
> the system() call does not work.
>
> Here is an example :
> int main(void)
> {
>    system("dir");
> }
>
> If I compile and run from the bash command line, it works great.
> Next, on a
> clean system, I copy the sample program, bash.exe, dir.exe and
> cygwin1.dll to a
> directory, and run bash.exe.  Now, I call the sample program, and it exits
> normally.
>
> My first thought was that stdout was not displaying correctly, so
> I tried :
> system("dir >junkfile") I got the same results... junkfile was
> created in the
> cygwin environment, and not in the raw bash environment.
>
> My next thought was that the paths were being confused somehow, so I tried
> compiling with system("$PWD/dir") and absolute paths... still, I
> get the same
> results.
>
> Any Ideas?

system() runs programs using /bin/sh; it is efectively

/bin/sh -c "your command line"

-andrej


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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