LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-07-2007, 08:00 PM   #1
fs11
Member
 
Registered: Aug 2006
Posts: 79

Rep: Reputation: 15
running binary using C


Hello all,

I am trying to run a binary (which is obtained from compiling another C/C++ code)using a C code...

For example:

MY new C Program {

RUN(thebinary) //the binary obtained from compiling another C/C++ code

}


Any help would be highly appreciable...

Thanks
 
Old 09-07-2007, 08:14 PM   #2
cpd05
Member
 
Registered: Jan 2006
Distribution: Debian
Posts: 90

Rep: Reputation: 15
Hey,

The execve system call executes another program within a program. See man 2 execve.

Is that any use...

Chris.
 
Old 09-08-2007, 03:24 AM   #3
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Rep: Reputation: 24
Wink

dear fs11

If u wanna run a binary then u can also use execl() call.

for example ur binary name is sample.bin and it is located in /root/sample.bin then write ur program as following,

int main(int argc, char **argv)
{
int t=0;
t=execl("/root/sample.bin","/root/sample.bin",(char*)0);

if(t==-1){
perror("EXECL FAILED");
}
return 0;
}

If u want to run ur binary sepratly from ur program use fork() sys call.

cheers !!!!!

Last edited by vdx; 09-08-2007 at 03:26 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running old binary with SuSE 9.1: getting error Ace27 SUSE / openSUSE 1 02-08-2007 04:15 AM
Running old binary on Fedora Core 3 Ace27 Linux - Newbie 1 01-30-2007 01:42 PM
Do I need binary 1 and binary 2 dvd iso for base install? salah-ad-din Debian 5 08-15-2006 04:43 PM
invalid binary "/usr/bin/postgres" while running postgresql ukrainet Linux - Newbie 1 12-01-2004 08:36 AM
Problem running execute binary file zekko Linux - General 18 08-08-2003 06:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration