system(); under Cygwin

F

Framcl

Hi all, im trying to use system(); with Cygwin but its not working...

look my code;
-------------
#include <stdlib.h>

int main(void)
{
printf("test");
system("dir");
return 0;
}
-------------

I'm doing gcc test.c -o test.exe

and im running test.exe under Windows with cygwin1.dll !

Thanks
-my email is (e-mail address removed)
 
E

Emmanuel Delahaye

In said:
Hi all, im trying to use system(); with Cygwin but its not working...

look my code;
-------------

Well, it could be better!
#include <stdlib.h>

#include said:
int main(void)
{
printf("test");

printf("test\n");
system("dir");
return 0;
}

Too weak!

gcc -W -Wall -ansi -pedantic -O2 test.c -o test.exe
and im running test.exe under Windows with cygwin1.dll !

What do you mean by 'it doesn't work'? Maybe it's just because the console
blinks and that you have no time to see the results. Add this at the end of
the main() (just before the 'return') :

system ("pause");
or
getchar();
 
M

Mark Gordon

Well, it could be better!




Too weak!

gcc -W -Wall -ansi -pedantic -O2 test.c -o test.exe

Also don't use test as a program name, especially if you are running the
executable from within bash.
What do you mean by 'it doesn't work'? Maybe it's just because the
console blinks and that you have no time to see the results. Add this
at the end of the main() (just before the 'return') :

system ("pause");
or
getchar();

If it's being run from Windows directly rather than from within a Cygwin
bash shell then the OP also needs to wander over to a Cygwin mailing
list or news group.
 
A

Alan Balmer

Hi all, im trying to use system(); with Cygwin but its not working...

look my code;
-------------
#include <stdlib.h>

int main(void)
{
printf("test");
system("dir");
return 0;
}
-------------

I'm doing gcc test.c -o test.exe

and im running test.exe under Windows with cygwin1.dll !

Thanks
-my email is (e-mail address removed)

Try naming it something else. "test" is a magic name under some Unix
shells.
 
B

bd

Hi all, im trying to use system(); with Cygwin but its not working...

look my code;
-------------
#include <stdlib.h>

int main(void)
{
printf("test");

This may not display anything. Use:
printf("test\n");
Or:
printf("test");
fflush(stdout);
system("dir");

The exact behaviour of system("dir") is implementation-defined.
 
P

Peter Shaggy Haywood

Groovy hepcat bd was jivin' on Fri, 08 Aug 2003 14:41:23 -0400 in
comp.lang.c.
Re: system(); under Cygwin's a cool scene! Dig it!
This may not display anything. Use:

Wrong. It must display something. The problem is *when* it is
displayed is unknown.
printf("test\n");
Or:
printf("test");
fflush(stdout);

It is better, in this case, to use the former option. It is
implementation defined whether the last line on a text stream requires
a terminating newline. So be safe and put a newline at the end of the
output.

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
 
V

Villy Kruse

Groovy hepcat bd was jivin' on Fri, 08 Aug 2003 14:41:23 -0400 in
comp.lang.c.

It is better, in this case, to use the former option. It is
implementation defined whether the last line on a text stream requires
a terminating newline. So be safe and put a newline at the end of the
output.

It has occurred that people don't see the output from the latter
option because the next shell prompt promptly overwrote it. This
has led to a very frustrating search for a non-existing bug.
Terminating the text with a new line will force the screen display to
scroll before the next shell prompt.


Villy
 
I

infecta

Originally posted by Framcl
Hi all, im trying to use system(); with Cygwin but its not working...

look my code;
-------------
#include <stdlib.h>

int main(void)
{
printf("test");
system("dir");
return 0;
}
-------------

I'm doing gcc test.c -o test.exe

and im running test.exe under Windows with cygwin1.dll !

Thanks
-my email is (e-mail address removed)



I Have the SAME problem, i discovered it with two winshit systems
I had win95c and win200
and put this:
int main(int ac,char **av)
{
system("/bin/sleep 60");
}

just to prove it
it works under win200, but it compiles on win95c, but doesnt work
system on win95c never runs that command with system ()
I don't know wtf is going on. It's the same cygwin on both os, but it
someone can help, thanks a lot
I need that function on both os's
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top