system_nosh(3)

NAME
esystem, system_eexecsp - execute a command with its arguments from a string without using a shell

SYNOPSIS
#include <stdlib.h>
#include <execs.h>

int esystem(const char *command);
int system_eexecsp(const char *command);

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

DESCRIPTION
esystem is an almost drop in replacement for system(3) provided by the libc. esystem parses the command string and runs the command directly, without using a shell. (system_eexecsp and esystem are synonyms).
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. The executable file is sought using the PATH environment variable as explained for execlp(3).

RETURN VALUE
These functions have the same return values of system(3).

EXAMPLE
The following program shows the usage of esystem:

#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");
	while (fgets(buf, BUFLEN, stdin) != NULL) {
		printf("Command: '%s' \n",buf);
		esystem(buf);
		printf("Command done\n");
	}
}

SEE ALSO
system(3),execs(3),s2argv(3),system_nosh(3)

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

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