Skip to content
Related Articles

Related Articles

doexec command in Linux with examples

View Discussion
Improve Article
Save Article
  • Last Updated : 02 Jun, 2022

doexec command in the Linux system is used to run an executable with an arbitrary argv[0]. It allows the user to argv[0] other than the name of the executable, which is by default passed.

Syntax:

doexec /path/to/executable argv[0] [argv[1-n]]

Options:

The argv list is used to send all options to the program being executed.

Example:

The following is a C program that is executed using the doexec command.

C




#include<stdio.h>
  
int main(int argc, char* argv[]){
    printf("The following is the list of the command-line arguments passed:\n");
    for(int i=0;i<argc;i++)
        printf("%d -> %s\n",i,argv[i]);
    return 0;
}


Using the following lines of codes we compile and run the executable.

gcc test.c -o test
doexec ./test "This is argv[0]"

Output:

The following is the list of the command-line arguments passed:

0 -> This is argv[0]

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!