how to execute exe files from within a file

C

Casanova

Hello!

How can I execute other exe files from within a executable file in GCC.
In TurboC 3, the spawn command executes a file and returns command to
the calling file.

whereas in GCC, the exec command only starts the execution of the new
file and does not return command to the calling file (the calling file
is terminated on the start of execution of the called file)

Is there any command in GCC that after executing the called file,
returns command to the calling file. The called file should be able to
be run in both concurrently as well as putting the calling file on
hold.

Thank You

Casanova
 
L

Lawrence Kirby

Hello!

How can I execute other exe files from within a executable file in GCC.
In TurboC 3, the spawn command executes a file and returns command to
the calling file.

The standard C function to run external commands is called system() and is
declared in <stdlib.h>. If that won't do what you want (it probably will)
then a good newsgroup to discuss gcc is gnu.gcc.help, but note that gcc is
just a compiler, your question is really about what libraries you happen
to be using with it.

Lawrence
 
C

Chris Croughton

How can I execute other exe files from within a executable file in GCC.
In TurboC 3, the spawn command executes a file and returns command to
the calling file.

The only method specified in standard C is system().
whereas in GCC, the exec command only starts the execution of the new
file and does not return command to the calling file (the calling file
is terminated on the start of execution of the called file)

Is there any command in GCC that after executing the called file,
returns command to the calling file. The called file should be able to
be run in both concurrently as well as putting the calling file on
hold.

No (it would be in the system library rather than in GCC itself, so
check about your system libraries). The conventional way to do it on
Unix is to fork(2) a process which then calls exec(3) to run the
program, while the original process wait(2)s for it to complete. Or you
can use popen(3) which allows you to write to the program's standard
input or read its standard output. But these are outside the standard C
specification (although they are in the POSIX specification so are
standard on systems which are conformant to that, like most Unix
systems).

[Note: numbers in parentheses like fork(2) refer to the man(1) section
numbers...]

Chris C
 
C

Casanova

in system() i wont be able to pass parameters. I have to open a exe
file which has to take command line parameters.

And just in case this is relevant. I am programming for the windows
platform
 
J

Jens.Toerring

Casanova said:
in system() i wont be able to pass parameters. I have to open a exe
file which has to take command line parameters.

Well, you pass the whole command line, including the parameters, to
system().
And just in case this is relevant. I am programming for the windows
platform

If this is relevant then you're off-topic here and you should better
ask in a MS programming group.
Regards, Jens
 
C

CBFalconer

Casanova said:
in system() i wont be able to pass parameters. I have to open a exe
file which has to take command line parameters.

And just in case this is relevant. I am programming for the windows
platform

Of course you can pass parameters - you can pass anything you like
in a text string. What is done with them is not dependant on the C
language, but on the shell which which you are actually
communicating. That is system dependant, and OT here.
 
K

Kenny McCormack

Chris Croughton said:
The conventional way to do it on Unix is to fork(2) a process which then
calls exec(3) to run the program, while the original process wait(2)s for
it to complete. Or you can use popen(3) which allows you to write to the
program's standard input or read its standard output. But these are
outside the standard C specification (although they are in the POSIX
specification so are standard on systems which are conformant to that,
like most Unix systems).

All of which is clearly irrelevant to (and most likely to utterly confuse)
the OP, since s/he is clearly a Windoze dork.
[Note: numbers in parentheses like fork(2) refer to the man(1) section
numbers...]

This, too.
 
C

Chris Croughton

All of which is clearly irrelevant to (and most likely to utterly confuse)
the OP, since s/he is clearly a Windoze dork.

If they are using GCC, as stated in the OP's question, they are likely
to have the rest of the libraries as well and be running with a
"Unix-like" environment such as Cygwin (under Windows) or DJGPP (under
MSDOS, likely since "Turbo C" was mentioned).
[Note: numbers in parentheses like fork(2) refer to the man(1) section
numbers...]

This, too.

Again, both Cygwin and DJGPP provide man.

Chris C
 

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