Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > system(); under Cygwin

Reply
Thread Tools

system(); under Cygwin

 
 
Framcl
Guest
Posts: n/a
 
      08-08-2003
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 http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Emmanuel Delahaye
Guest
Posts: n/a
 
      08-08-2003
In 'comp.lang.c', (E-Mail Removed) (Framcl) wrote:

> 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 <stdio.h>

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


printf("test\n");

> system("dir");
> return 0;
> }
> -------------
>
> I'm doing gcc test.c -o test.exe


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();

--
-ed- (E-Mail Removed) [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
 
Reply With Quote
 
 
 
 
Mark Gordon
Guest
Posts: n/a
 
      08-08-2003
On 8 Aug 2003 06:13:15 GMT
Emmanuel Delahaye <(E-Mail Removed)> wrote:

> In 'comp.lang.c', (E-Mail Removed) (Framcl) wrote:
>
> > 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 <stdio.h>
>
> > int main(void)
> > {
> > printf("test");

>
> printf("test\n");
>
> > system("dir");
> > return 0;
> > }
> > -------------
> >
> > I'm doing gcc test.c -o test.exe

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

> > 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();


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.
--
Mark Gordon
 
Reply With Quote
 
Alan Balmer
Guest
Posts: n/a
 
      08-08-2003
On 7 Aug 2003 22:04:52 -0700, (E-Mail Removed) (Framcl) wrote:

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


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

--
Al Balmer
Balmer Consulting
(E-Mail Removed)
 
Reply With Quote
 
bd
Guest
Posts: n/a
 
      08-08-2003
On Thu, 07 Aug 2003 22:04:52 -0700, Framcl wrote:

> 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.
<ot>Try system("ls"), since you're using cygwin</ot>

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


--
Freenet distribution not available
There is one difference between a tax collector and a taxidermist --
the taxidermist leaves the hide.
-- Mortimer Caplan

 
Reply With Quote
 
Peter Shaggy Haywood
Guest
Posts: n/a
 
      08-12-2003
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!

>On Thu, 07 Aug 2003 22:04:52 -0700, Framcl wrote:
>
>> 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:


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"?
 
Reply With Quote
 
Villy Kruse
Guest
Posts: n/a
 
      08-12-2003
On Tue, 12 Aug 2003 00:23:47 GMT,
Peter "Shaggy" Haywood <(E-Mail Removed)> wrote:


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


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


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
 
Reply With Quote
 
infecta
Guest
Posts: n/a
 
      08-14-2003

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

--
Posted via http://dbforums.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Installing Win32::OLE under cygwin usenet Perl 2 05-22-2005 03:45 AM
confirm unsubscribe from cygwin@cygwin.com cygwin-help@cygwin.com Python 0 09-05-2003 04:42 PM
WELCOME to cygwin@cygwin.com cygwin-help@cygwin.com Python 1 09-05-2003 07:46 AM
confirm unsubscribe from cygwin-announce@cygwin.com cygwin-announce-help@cygwin.com Python 0 09-05-2003 01:29 AM
confirm unsubscribe from cygwin@cygwin.com cygwin-help@cygwin.com Python 0 09-04-2003 06:34 PM



Advertisments