473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

system(); under Cygwin

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 fr****@cgocable.ca
Nov 13 '05 #1
6 5140
In 'comp.lang.c', fr****@cgocable.ca (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- em**********@noos.fr [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/
Nov 13 '05 #2
On 8 Aug 2003 06:13:15 GMT
Emmanuel Delahaye <em**********@noos.fr> wrote:
In 'comp.lang.c', fr****@cgocable.ca (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
Nov 13 '05 #3
On 7 Aug 2003 22:04:52 -0700, fr****@cgocable.ca (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 fr****@cgocable.ca


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

--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 13 '05 #4
bd
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 fr****@cgocable.ca


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

Nov 13 '05 #5
On Tue, 12 Aug 2003 00:23:47 GMT,
Peter "Shaggy" Haywood <ph******@alphalink.com.au.STOP.SPAM> 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
Nov 13 '05 #6

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 fr****@cgocable.ca


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
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jörg Maier | last post by:
Hey guys, i have a big problem using Tkinter and pexpect in cygwin. i try to program an winscp-like rsync Program for all posix Platforms (linux, macosx, cygwin). i got a class SslConnection...
4
by: Bob Roberts | last post by:
How can I make it so that I can pass anything into os.system() any command that I would type into the command line (bash on cygwin)? For example, "lower" is a small script of mine that I use...
4
by: Andreou Giannis | last post by:
Allthough it is possible to build modules in Python2.3.3 and distutils with cygwin, by running: setup.py build --compiler=cygwin (after i created the libpython23.a) running: setup.py install...
0
by: dw | last post by:
Pehaba, does anyone knows how to install MySQLdb on cygwin? - test device: MySQLdb 0.9.2.0 targz + cygwin 1.5.7-cr-0x9e + python 2.3.3 on cygwin + mysql 4.0.17 win32 - modified setup.py's...
6
by: Steve Holden | last post by:
Does anyone know the workaround for this error, encountered when trying to build PIL 1.1.4 from source under cygwin (Python 2.3.3)? running build_ext building '_imaging' extension gcc...
3
by: RMJ | last post by:
After installing Enthought's python and typing 'python' from within cygwin the program hangs with no output. I do not remember this being the case with earlier versions of Enthought python. Is...
6
by: gry | last post by:
I want to write some kind of install script for my python app that will add c:\cygwin\usr\bin to the system path. I don't want to walk around to 50 PC's and twiddle through the GUI to: My...
12
by: Jamie Ruff | last post by:
I am having problems with making system calls on Windows under Cygwin that involve the use of redirection operators and pipes. For example, the line below will cat two files, but the next command...
0
by: MacPerl | last post by:
Hi there, I recently had to update my old cygwin installation to a newer version. I'm not quite sure what version I updated from or to - but the old version came with perl 5.6, the one I updated...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.