system(); under Cygwin

Discussion in 'C Programming' started by Framcl, Aug 8, 2003.

  1. Framcl

    Framcl Guest

    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
    Framcl, Aug 8, 2003
    #1
    1. Advertising

  2. In 'comp.lang.c', (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- [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/
    Emmanuel Delahaye, Aug 8, 2003
    #2
    1. Advertising

  3. Framcl

    Mark Gordon Guest

    On 8 Aug 2003 06:13:15 GMT
    Emmanuel Delahaye <> wrote:

    > In 'comp.lang.c', (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
    Mark Gordon, Aug 8, 2003
    #3
  4. Framcl

    Alan Balmer Guest

    On 7 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");
    >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


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

    --
    Al Balmer
    Balmer Consulting
    Alan Balmer, Aug 8, 2003
    #4
  5. Framcl

    bd Guest

    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


    --
    Freenet distribution not available
    There is one difference between a tax collector and a taxidermist --
    the taxidermist leaves the hide.
    -- Mortimer Caplan
    bd, Aug 8, 2003
    #5
  6. 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"?
    Peter Shaggy Haywood, Aug 12, 2003
    #6
  7. Framcl

    Villy Kruse Guest

    On Tue, 12 Aug 2003 00:23:47 GMT,
    Peter "Shaggy" Haywood <> 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
    Villy Kruse, Aug 12, 2003
    #7
  8. Framcl

    infecta Guest

    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




    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
    infecta, Aug 14, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    428
  2. Replies:
    0
    Views:
    426
  3. WELCOME to

    , Sep 3, 2003, in forum: Python
    Replies:
    1
    Views:
    510
    Robin Becker
    Sep 5, 2003
  4. Replies:
    0
    Views:
    410
  5. Gordon
    Replies:
    1
    Views:
    127
    Helgi Briem
    Sep 10, 2003
Loading...

Share This Page