473,408 Members | 1,857 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,408 software developers and data experts.

how execute exe in c

Hello,

I would like to know how i can execute an exe file using c prgogram? I
am using the GNU GCC in Linux Could someone explain me how to do that ?
send mail chellappa at gmail .com
Thanks in advance...
Regards
chellappa

Nov 15 '05 #1
22 8955
Tom
use :

system("Exename");

this will execute the exe file in a new shell

"chellappa" <N.*********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hello,

I would like to know how i can execute an exe file using c prgogram? I
am using the GNU GCC in Linux Could someone explain me how to do that ?
send mail chellappa at gmail .com
Thanks in advance...
Regards
chellappa

Nov 15 '05 #2
I think execution of system() function is OS specific. The parameter
passed to the system() function will be executed by the native OS
runtime environment. So i think system(.exe) in linux will not get
executed.

Nov 15 '05 #3

chellappa wrote:
Hello,

I would like to know how i can execute an exe file using c prgogram? I
am using the GNU GCC in Linux Could someone explain me how to do that ?
send mail chellappa at gmail .com
Thanks in advance...
Regards
chellappa

system("command") is a good choice, but you can do It more "leet", like
defining a char where you store your exe hex values, then execute it
through a pointer from a stream, or something like that.
For 99% of users the first choice is the most common, that if you
don't plan to do something unusual like in the second choice :)

Nov 15 '05 #4
jaekkay <ja*****@gmail.com> wrote:
I think execution of system() function is OS specific. The parameter
passed to the system() function will be executed by the native OS
runtime environment. So i think system(.exe) in linux will not get
executed.


First of all, it seems OP was talking about an "executable file", not
an "exe", so there is no reason to expect system( "/bin/ls" ), for
example, not to work. Also...

It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:

If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #5
jaekkay wrote:
I think execution of system() function is OS specific. The parameter
passed to the system() function will be executed by the native OS
runtime environment. So i think system(.exe) in linux will not get
executed.


Please provide context when posting, there is absolutely no guarantee
that other people will *ever* see the post you are replying to. Search
this group for "google context" without the quotes to see the hundreds
of messages telling people how to post correctly using google. Then
complain at Google for them making you look like an idiot.

As to what you are saying, it is even worse than you thought. The string
is actually passed to the shell to be executed, so the behaviour depends
not just on the OS but on the behaviour of the default shell (what you
have as /bin/sh on Linux).

However, depending on how you Linux system is configured you might well
be able to run a DOS or Windows application by doing
system("app.exe");

Doing so is the *only* support in standard C for running another
executable from within a C program. If that is not enough then the OP
needs to ask on a Linux group.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #6
I am sorry for that. This is the first time that i am posting a reply.
I should have read the procedures before posting.
Flash Gordon wrote:
jaekkay wrote:
I think execution of system() function is OS specific. The parameter
passed to the system() function will be executed by the native OS
runtime environment. So i think system(.exe) in linux will not get
executed.


Please provide context when posting, there is absolutely no guarantee
that other people will *ever* see the post you are replying to. Search
this group for "google context" without the quotes to see the hundreds
of messages telling people how to post correctly using google. Then
complain at Google for them making you look like an idiot.

As to what you are saying, it is even worse than you thought. The string
is actually passed to the shell to be executed, so the behaviour depends
not just on the OS but on the behaviour of the default shell (what you
have as /bin/sh on Linux).

However, depending on how you Linux system is configured you might well
be able to run a DOS or Windows application by doing
system("app.exe");

Doing so is the *only* support in standard C for running another
executable from within a C program. If that is not enough then the OP
needs to ask on a Linux group.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.


Nov 15 '05 #7
Pacher R. Dragos wrote:
chellappa wrote:
Hello,

I would like to know how i can execute an exe file using c prgogram? I
am using the GNU GCC in Linux Could someone explain me how to do that ?
send mail chellappa at gmail .com
Thanks in advance...
system("command") is a good choice, but you can do It more "leet", like
defining a char where you store your exe hex values, then execute it
through a pointer from a stream, or something like that.


If by "leet" you mean completely stupid or brain dead, then possibly.
However, on a number of systems this will not work, and the number of
systems it does not work is more likely to increase than decrease.
For 99% of users the first choice is the most common, that if you
don't plan to do something unusual like in the second choice :)


When system is not suitable you go to system specific extensions like
the exec family of functions provided on *nix, you don't go to stupid
tricks like you suggested.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #8
Tom
> Doing so is the *only* support in standard C for running another
executable from within a C program. If that is not enough then the OP
needs to ask on a Linux group.
flash, are you sure that this is the only support to run another program..?
ya you are correct when you say standard C,
but considering that OP is trying to run his executable on a linux OS, you
can always do an exec call
like :
execl("/usr/bin/date","date",0);So, if OP was particular on getting this
program running, then he can as well, use this method to run his executable.
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:ji************@news.flash-gordon.me.uk... jaekkay wrote:
I think execution of system() function is OS specific. The parameter
passed to the system() function will be executed by the native OS
runtime environment. So i think system(.exe) in linux will not get
executed.


Please provide context when posting, there is absolutely no guarantee that
other people will *ever* see the post you are replying to. Search this
group for "google context" without the quotes to see the hundreds of
messages telling people how to post correctly using google. Then complain
at Google for them making you look like an idiot.

As to what you are saying, it is even worse than you thought. The string
is actually passed to the shell to be executed, so the behaviour depends
not just on the OS but on the behaviour of the default shell (what you
have as /bin/sh on Linux).

However, depending on how you Linux system is configured you might well be
able to run a DOS or Windows application by doing
system("app.exe");

Doing so is the *only* support in standard C for running another
executable from within a C program. If that is not enough then the OP
needs to ask on a Linux group.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.

Nov 15 '05 #9
Tom <Th***************@gmail.com> wrote:
flash, are you sure that this is the only support to run another program..?
ya you are correct when you say standard C,
And that's all that matters in this newsgroup.
execl("/usr/bin/date","date",0);So, if OP was particular on getting this
program running, then he can as well, use this method to run his executable.


Then OP could head to a system-specific newsgroup to get help with
that.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #10
chellappa wrote:
Hello,

I would like to know how i can execute an exe file using c prgogram? I
am using the GNU GCC in Linux Could someone explain me how to do that ?
send mail chellappa at gmail .com
Even though it is considered a poor idea, and sometimes considered rude,
to ask for e-mail responses, I am e-mailing this as well as posting it.
There are several reasons that you don't want responses by e-mail, but
the most important is that you have no way of judging the answers you
get. When an answer is posted to the newsgroup, it is subject to the
scrutiny of other posters and so can be corrected when wrong,
incomplete, or misleading.

The simple answer to your question is to use system(). It is documented
both in the docs for your implementation and in even the most basic C
text.

There are other approaches that are specific to certain platforms or
implementations. Among the more used are the exec*() family which is
POSIX and the spawn*() family which is not. Neither of these is
necessarily present in a C implementation, since they are non-standard.
That makes them off-topic in <news:comp.lang.c>, so if you choose to
use them questions belong in newsgroups specific to your platform or C
implementation.
Thanks in advance...
That is often considered rude, since it presumes relationships of
expectation and obligation.
Regards
But that's nice.
chellappa

Nov 15 '05 #11
Martin Ambuhl <ma*****@earthlink.net> wrote:
Thanks in advance...
That is often considered rude, since it presumes relationships of
expectation and obligation.


Do you think so? I've always considered it to be friendly, but
perhaps that's just me.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Nov 15 '05 #12
Christopher Benson-Manica said the following, on 10/21/05 11:27:
Martin Ambuhl <ma*****@earthlink.net> wrote:

Thanks in advance...


That is often considered rude, since it presumes relationships of
expectation and obligation.

Do you think so? I've always considered it to be friendly, but
perhaps that's just me.


I've usually regarded it as friendly, too, unless the overall tone of
the message suggests otherwise. The argument against it, I think, is
that it might come across as "I can't be bothered to thank you after you
answer."

For that reason, I like a formula along the lines of "Thank you for your
time / interest."

--
Rich Gibbs
ri*****@gmail.com
"If you find yourself in a hole, stop digging." -- Will Rogers

Nov 15 '05 #13
Tom
>
And that's all that matters in this newsgroup.
i assume that , that was the premise of comp.std.c to stick to standards
strictly to C

and comp.lang.c was to tread into all paths related to C..
anyways we will let it go at that.. !

it was a good discussion.

"Christopher Benson-Manica" <at***@nospam.cyberspace.org> wrote in message
news:dj**********@chessie.cirr.com... Tom <Th***************@gmail.com> wrote:
flash, are you sure that this is the only support to run another
program..?
ya you are correct when you say standard C,


And that's all that matters in this newsgroup.
execl("/usr/bin/date","date",0);So, if OP was particular on getting this
program running, then he can as well, use this method to run his
executable.


Then OP could head to a system-specific newsgroup to get help with
that.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.


Nov 15 '05 #14
Tom wrote:
Doing so is the *only* support in standard C for running another
executable from within a C program. If that is not enough then the OP
needs to ask on a Linux group.
flash, are you sure that this is the only support to run another program..?
ya you are correct when you say standard C,


Which is what I stated above, standard C.
but considering that OP is trying to run his executable on a linux OS, you
can always do an exec call
like :
execl("/usr/bin/date","date",0);So, if OP was particular on getting this
program running, then he can as well, use this method to run his executable.


I also stated in the above that if that was not enough ask in a Linux
group, I did this in full knowledge that in a Linux or Unix group they
can suggest lots of other ways of doing things which have advantages
over the system call (and I even know some of them myself, including the
exec family of functions). I did this because in a Linux or Unix group
they might know what is wrong with your suggestion above, which header
you failed to specify as providing the prototype etc. (I know, but that
is not for discussion here).

For the record, I also know the Windows alternatives to system, but
would no more discus those here than the POSIX ones.

So please, in future, don't follow up saying in <os-of-choice> you can
use such and such a function when people (as I did) have already
suggested going else where if the standard solution is not sufficient.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #15
jaekkay wrote:
I am sorry for that. This is the first time that i am posting a reply.
I should have read the procedures before posting.
Your reply belongs *after* the text you are replying to, after anything
not relevant has been deleted, bit before. Look at the bulk of posts to
the group to see how posts should look.
Flash Gordon wrote:
jaekkay wrote:


<snip>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 15 '05 #16
On 2005-10-21, Tom <Th***************@Gmail.com> wrote:

And that's all that matters in this newsgroup.

i assume that , that was the premise of comp.std.c to stick to
standards strictly to C


When you make an assumption, it makes an ass out of you and
umption.

comp.std.c is for discussion *of* the C standard.

--
Neil Cerutti
Nov 15 '05 #17
On 2005-10-21, Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote:
Martin Ambuhl <ma*****@earthlink.net> wrote:
> Thanks in advance...

That is often considered rude, since it presumes relationships of
expectation and obligation.


Do you think so? I've always considered it to be friendly, but
perhaps that's just me.


I don't consider it rude. It is presumptious. The reader may not
choose to help you at all. I generally say something like,
"Thanks for taking the time to read my question."

--
Neil Cerutti
Nov 15 '05 #18
"Tom" <Th***************@Gmail.com> writes:
And that's all that matters in this newsgroup.

i assume that , that was the premise of comp.std.c to stick to standards
strictly to C

and comp.lang.c was to tread into all paths related to C..
anyways we will let it go at that.. !


No, you've misunderstood the purposes of the newsgroups.

comp.lang.c is for discussion of standard C, as defined by the ISO
standard(s). (The current standard is C99, but the older C89/C90
standard is still discussed. We also sometimes discuss pre-standard C
in historical contexts.) System-specific extensions are off-topic.

comp.std.c is for discussion of the C standard as a document, not for
discussion of the language itself. For example, proposals for changes
to the standard or discussions of errors or ambiguities in the
standard belong in comp.std.c. Discussions of the language defined by
the standard belong in comp.lang.c. Discussions of things not defined
by the standard belong elsewhere.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #19
To review ...
chellappa wrote near the end of his message aksing for help (by e-mail,
no less):
Thanks in advance...
Of this, Martin Ambuhl wrote:That is often considered rude, since it presumes relationships of
expectation and obligation.
To which we have three responses ...
Christopher Benson-Manica: Do you think so? I've always considered it to be friendly, but
perhaps that's just me.
Rich Gibbs: I've usually regarded it as friendly, too, unless the overall tone of the message suggests otherwise. The argument against it, I think, is that it might come across as "I can't be bothered to thank you after you answer."
For that reason, I like a formula along the lines of "Thank you for your time / interest."
Neil Cerutti: I don't consider it rude. It is presumptious. The reader may not
choose to help you at all. I generally say something like,
"Thanks for taking the time to read my question."


The TIA cliche is well established in usenet postings, so it is no
surprise that many people use it as a "friendly" formula. But I doubt
very much that many posters use it before seeing it here. It is, rather,
from the lexicon of bill collectors, who use it and similar formulae
precisely because they set up a dominance relationship. It asserts an
expectation that certain acts are forthcoming, and that the asker has a
right to expect them. It further asserts that the time and effort of
the person answering is not worth bothering about; the asker can't be
bothered thanking for help received. "I've posted a question. You
answer it. I'm too fucking important to bother with you beyond that."


Nov 15 '05 #20
Martin Ambuhl <ma*****@earthlink.net> wrote in
news:wf******************@newsread3.news.atl.earth link.net:
To review ...
chellappa wrote near the end of his message aksing for help (by
e-mail, no less):
Thanks in advance...
Of this, Martin Ambuhl wrote:
That is often considered rude, since it presumes relationships of
expectation and obligation.


....
The TIA cliche is well established in usenet postings, so it is no
surprise that many people use it as a "friendly" formula. But I doubt
very much that many posters use it before seeing it here. It is,
rather, from the lexicon of bill collectors, who use it and similar
formulae precisely because they set up a dominance relationship. It
asserts an expectation that certain acts are forthcoming, and that the
asker has a right to expect them. It further asserts that the time
and effort of the person answering is not worth bothering about; the
asker can't be bothered thanking for help received.


Very well put.

I tried making the same point once, but it seems the cliche has
become very popular:

http://groups.google.com/group/comp....b4776c0523ab9/

--
A. Sinan Unur <1u**@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
Nov 15 '05 #21
In article <wf******************@newsread3.news.atl.earthlink .net>,
Martin Ambuhl <ma*****@earthlink.net> wrote:
....
The TIA cliche is well established in usenet postings, so it is no
surprise that many people use it as a "friendly" formula. But I doubt
very much that many posters use it before seeing it here. It is, rather,
from the lexicon of bill collectors, who use it and similar formulae
precisely because they set up a dominance relationship. It asserts an
expectation that certain acts are forthcoming, and that the asker has a
right to expect them. It further asserts that the time and effort of
the person answering is not worth bothering about; the asker can't be
bothered thanking for help received. "I've posted a question. You
answer it. I'm too fucking important to bother with you beyond that."


I don't disagree with this, but wish to add some comments of my own.

Leaving aside the fact that CLC is a joke newsgroup which is constantly
being trolled by these pseudo-well-meaning-foreigners, let's consider what
the TIA thing means, or should mean, in real-life business email.

I think that, used correctly, it is a Good Thing. That is, if you are
sending email with the intent of getting other people to do something (that
is, contains "action items" for other people), then it makes sense to end
it (the email) with "Thanks.". As in, "Fred, I need you to run that report
today. Thanks." The "Thanks" is a signal (code, if you will) that Fred is
expected to do it - i.e., this message is not "for informational purposes
only". Used judiciously, this is a useful thing. Often, it is not
otherwise clear whether the expectation of action is there or not.

The problem is that some people abuse it. In the best of circumstances, it
should convey a message of "I did my part, now you do yours". Unfortunately,
some people end every email with "Thanks", to, as you allude to above,
sugar-coat an ugly message. Which is often, "you do this, you do that, you
do ... (without any 'I did my part' component)".

Nov 15 '05 #22
In article <wf******************@newsread3.news.atl.earthlink .net>,
Martin Ambuhl <ma*****@earthlink.net> wrote:
....
The TIA cliche is well established in usenet postings, so it is no
surprise that many people use it as a "friendly" formula. But I doubt
very much that many posters use it before seeing it here. It is, rather,
from the lexicon of bill collectors, who use it and similar formulae
precisely because they set up a dominance relationship. It asserts an
expectation that certain acts are forthcoming, and that the asker has a
right to expect them. It further asserts that the time and effort of
the person answering is not worth bothering about; the asker can't be
bothered thanking for help received. "I've posted a question. You
answer it. I'm too fucking important to bother with you beyond that."


I don't disagree with this, but wish to add some comments of my own.

Leaving aside the fact that CLC is a joke newsgroup which is constantly
being trolled by these pseudo-well-meaning-foreigners, let's consider what
the TIA thing means, or should mean, in real-life business email.

I think that, used correctly, it is a Good Thing. That is, if you are
sending email with the intent of getting other people to do something (that
is, contains "action items" for other people), then it makes sense to end
it (the email) with "Thanks.". As in, "Fred, I need you to run that report
today. Thanks." The "Thanks" is a signal (code, if you will) that Fred is
expected to do it - i.e., this message is not "for informational purposes
only". Used judiciously, this is a useful thing. Often, it is not
otherwise clear whether the expectation of action is there or not.

The problem is that some people abuse it. In the best of circumstances, it
should convey a message of "I did my part, now you do yours". Unfortunately,
some people end every email with "Thanks", to, as you allude to above,
sugar-coat an ugly message. Which is often, "you do this, you do that, you
do ... (without any 'I did my part' component)".

Nov 15 '05 #23

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

Similar topics

2
by: Tim Williams | last post by:
I'm trying to write a simple python program to access a MySQL database. I'm having a problem with using MySQLdb to get the results of a SQL command in a cursor. Sometimes the cursor.execute works,...
2
by: Matt | last post by:
I want to exexute stored procedure in ASP, but it has error "Microsoft VBScript compilation (0x800A0401) Expected end of statement" on line (1). The stored procedure "sp_emp" contain "select *...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
9
by: PyPK | last post by:
Hi if I have a function called tmp=0 def execute(): tmp = tmp+1 return tmp also I have def func1(): execute() ....
5
by: Gustavo Randich | last post by:
Hello, I'm writing an automatic SQL parser and translator from Informix to DB2. Now I'm faced with one of the most difficult things to translate, the "foreach execute procedure" functionality...
2
by: Norman Fritag | last post by:
Hi there The below code executes some queries. As newbie I was wondering weather you are better of using connection execute or command execute to execute queries? I am asking as...
2
by: Dune | last post by:
I'm trying to execute an aspx page by calling Server.Execute. The aspx page I'm trying to execute is in a different web app from the aspx page containing the Server.Execute statement. A slightly...
8
by: johnlichtenstein | last post by:
I am using cx_Oracle and MySQLdb to pull a lot of data from some tables and I find that the cursor.execute method uses a lot of memory that never gets garbage collected. Using fetchmany instead of...
1
by: gglegrp112 | last post by:
Is it possible to send an array as a parameter for an execute method in dbapi2 module? I'm using adodbapi and try to perfrom the following SQL query: select * from item where storeid in ('01',...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.