Function to execute a binary incase of code.
Hello friends,
I am working currently in C programming. For some reasons, in the code, i have to give a path to the binary(executable), which can be directly used instead of any code.
For eg :-
if(condition_satisfied){
execve'absolute_path_to_executable_file'
}
With this, it should execute this binary file. Is this possible? If yes, Kindly let me know. Thank you for your time. :-) ):P
Re: Function to execute a binary incase of code.
I think you can use the exec() function for this.
Paul
Re: Function to execute a binary incase of code.
Quote:
Originally Posted by
akshay.sulakhe
Hello friends,
I am working currently in C programming. For some reasons, in the code, i have to give a path to the binary(executable), which can be directly used instead of any code.
For eg :-
if(condition_satisfied){
execve'absolute_path_to_executable_file'
}
With this, it should execute this binary file. Is this possible? If yes, Kindly let me know. Thank you for your time. :-) ):P
hi
you can use any kind of exec calls try: man -k exec to see the different calls. i am sure one of the will satisfy your claim. the normal exec is ok too.
ciao
Re: Function to execute a binary incase of code.
Quote:
Originally Posted by
akshay.sulakhe
With this, it should execute this binary file. Is this possible?
You have the code written, how about you try it and find out?
Re: Function to execute a binary incase of code.
Keep in mind that if you just use exec(), your program will be replaced by the program you exec(), so any code after the exec() in your program won't get executed.
For example:
Code:
foo=bar;
if(condition)
{
exec(program);
}
foo=baz; //If "condition" is true, you'll never get to this line.