---
name: "execs"
section: "3"
platform: "linux"
package: "libexecs-dev"
version: "1.4-2+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/execs"
---

# execs(3)

execute a file taking its arguments from a string

## NAME

execs, execsp, execspe - execute a file taking its arguments from a string

## SYNOPSIS

**#include \<unistd.h\>**\
 **#include \<execs.h\>**

**int execs(const char \****path***, const char \****args***);**\
 **int execse(const char \****path***, const char \****args***, char \*const** *envp***\[\]);**\
 **int execsp(const char \****args***);**\
 **int execspe(const char \****args***, char \*const** *envp***\[\]);**

**int eexecs(const char \****path***, char \****args***);**\
 **int eexecse(const char \****path***, char \****args***, char \*const** *envp***\[\]);**\
 **int eexecsp(char \****args***);**\
 **int eexecspe(char \****args***, char \*const** *envp***\[\]);**

These functions are provided by libexecs and libeexecs. Link with *-lexecs* or *-leexecs*.

## DESCRIPTION

This group of functions extends the family of [**exec**(3)](/exec/3.md) provided by the libc.\
 **execs**, **execse**, **execsp** and **execspe** are similar to [**execv**(3)](/execv/3.md), [**execve**(2)](/execve/2.md), [**execvp**(3)](/execvp/3.md) and [**execvpe**(3)](/execvpe/3.md), respectively, but take the command line arguments for the file to execute  (and the also the command name for [**execsp**(3)](/execsp/3.md) and [**execspe**(3)](/execspe/3.md)) by parsing a command string *args*.\
 Command arguments in *args* are delimited by space characters (blank, tabs or new lines). Single or double quotes can be used to delimitate command arguments including spaces and a non quoted backslash (**\\**) is the escape character to protect the next char.\
 **execs**, **execse**, **execsp** and **execspe** do not use dynamic allocation but require space on the stack to store an entire copy of *args*. **eexecs**, **eexecse**, **eexecsp** and **eexecspe** do not use extra stack space but modify *args*.

In case the same argv should be used for several exec command, use [**s2argv**(3)](/s2argv/3.md) to parse the args just once.

## RETURN VALUE

These functions return only if an error has occurred. The return value is always -1. The failure cases and errno values are those specified for [**execve**(2)](/execve/2.md).

## EXAMPLE

The following program demonstrates the use of **execs**:

```
#include <stdio.h>
#include <unistd.h>
#include <execs.h>
#define BUFLEN 1024
int main(int argc, char *argv)
{
	char buf[BUFLEN];
	printf("type in a command and its arguments, e.g. 'ls -l'\n");
	if (fgets(buf, BUFLEN, stdin) != NULL) {
		execsp(buf);
		printf("exec error\n");
	}
}
```

## SEE ALSO

[**exec**(3)](/exec/3.md),[**s2argv**(3)](/s2argv/3.md)

## BUGS

Bug reports should be addressed to \<info@virtualsquare.org\>

## AUTHOR

Renzo Davoli \<renzo@cs.unibo.it\>
