Questions tagged [execl]

execl() is a C library function which is used to replace the current process image with a new process image. It belongs to the family of exec() functions and prototyped in unistd.h.

execl() is a C library function which is used to replace the current process image with a new process image. It belongs to the familt of exec() functions and prototyped in unistd.h.

The Function Prototype

int execl(const char *path, const char *arg, ...);

where,

  • The first argument is the name of a file that is to be executed.
  • The const char *arg and subsequent arguments (if any) can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.

Return Value

The various exec() functions only return if an error has occurred. The return value is -1, and errno is set to indicate the error.

Check the Main page for more details.

120 questions
0
votes
1 answer

How to read pipe input from another file?

In my program (main.c) I fork a process and then I need to send data via pipe to child process. After execl system call child process continues its life in process.c file. With setting standard input of that child to file descriptor of its parent I…
kntgu
  • 184
  • 1
  • 2
  • 14
0
votes
1 answer

Expected parameter declarator error when trying to use execle

So I'm a new learner, and I can't seem to figure out why I'm getting the following errors when trying to compile this code. For reference, I'm learning out of the "Head First C" book and this is an example they give early on in chapter 9. Although…
Essence
  • 75
  • 2
  • 8
0
votes
1 answer

execl in externnotify C code not working in voicemail part of Asterisk

I am struggling with this problem. In Asterisk, I need to execute an external script after leaving a voicemail message. For this, I enabled externnotify in voicemail.conf but it was not working. So I searched in C code and found the related code.…
AmirA
  • 133
  • 2
  • 15
0
votes
1 answer

execl + find + -exec: missing argument to `-exec'

I am trying to run execlp with find ... -exec ..., and the find program consistently tells me: find: missing argument to `-exec' What could be wrong? When I run find with these arguments on my shell, it succeeds. My function calls follow (after…
JellicleCat
  • 28,480
  • 24
  • 109
  • 162
0
votes
1 answer

execl error == "file exists" when the file doesn't exist

I'm trying to understand the error returned by execl when it is trying to launch a file that doesn't exist. Here is my code for this experiment, where main calls the function spawn1 that will create the fork and try to launch execl: # include…
Jonath P
  • 519
  • 5
  • 16
0
votes
0 answers

How to use cd and vi in execl function

I want to use the execl function to invoke both commands cd and vi from my c program, but it does not work. This is what I did for rm and ls: execl("/bin/ls", "ls", NULL); execl("/bin/rm", "rm", args[1], NULL); //args is the array containing the…
0
votes
2 answers

How does execl deal with "/bin/sh" in Linux?

I read about APUE 3rd, 8.13, system Function, and I saw a version of system function implementation without signal handling.Code is like below: #include #include #include int system(const char *cmdstring) …
cong
  • 1,105
  • 1
  • 12
  • 29
0
votes
1 answer

tar command in execl using busybox. Error: no such file or directory

I have a linux based device that runs c++ code using QT framework. Using QProcess is not an option, since we don't have the QT compiled to support it. I can't create a tar.gz archive using execl(). It returns -1(fail) and error is "No such file or…
ionutCb
  • 13
  • 6
0
votes
1 answer

iwlist tries to scan all interfaces when called using execl

I am doing a standard fork/execl in C++ on my Ubuntu PC to scan for Wi-Fi SSIDs. It looks like the interface name is not taking effect when called with excel. execl( "/sbin/iwlist", "wlp4s0", "scanning", (char*) NULL ); This succeeds but I get…
Nathan Owen
  • 155
  • 10
0
votes
2 answers

The usage of execlp() in a c-program

I have a question regarding execlp() in c. I have the following programm: #include #include #include #include #include #include #include #include void…
Natascha
  • 59
  • 1
  • 3
  • 8
0
votes
0 answers

C - using dup to redirect stdout to execl(binary file)'s input

I need help with the following program, It's supposed to fork() two childs, child1 should send two random numbers, in a string separated by space, to child2 trough pipe, wait 1 sec and do it again until it receives SIGUSR1 from the parent(parent…
Petr Kroupa
  • 53
  • 3
  • 8
0
votes
2 answers

What will happen if I fork and exec in parent and child?

Here is my sample code called server.c (have removed include's to keep it simple). int main() { for(int i = 0; i < 10; i++) { fork(); execl("./client", "./client", NULL); } if (wait(NULL) == -1) perror("error with…
posixKing
  • 408
  • 1
  • 8
  • 17
0
votes
1 answer

Determine which binary will run via execlp in advance

Edit #1 The "Possible duplicates" so far are not duplicates. They test for the existence of $FILE in $PATH, rather than providing the full path to the first valid result; and the top answer uses bash command line commands, not pure c. Original…
Cloud
  • 18,753
  • 15
  • 79
  • 153
0
votes
1 answer

Sending and receiving character array using piping through argv in C

So, I'm trying to create a pipe that sends char arrays back and forth through pipes that connect through argv[]. Right now, I'm stuck at receiving the array (param which is sent to c_param from the parent to the child.) in interface.c to receiving…
nwfistere
  • 355
  • 4
  • 15
0
votes
1 answer

Read/write stdin/out for bash interpreter linux, fork - execl

I've been trying to write a program that will send and receive commands to a bash shell (/bin/sh). Like a wrapper program around a bash shell. So, I could write to stdin "cd ~/Desktop", then write again "ls" and I will receive a listing of the files…