More on exec
- execvp and execlp search for the executable in the environment variable PATH
- The standard library functions getenv, setenv, unsetenv and putenv
- #include <stdlib.h>
- char *getenv(const char *name);
- int setenv(const char *name, const char *value, int overwrite);
- overwrite = 0, value not changed if the value was not set.
- overwrite != 0, value changed if the value was not set
- int putenv(char *string);
- int unsetenv(const char *name);
- Values are stored as strings: "var=value"
- Running scripts:
- As we have discussed if the file begins with #! /path/to/interpreter interpreter_args
- There can be only one argument in the first line
- In bash
- $0 is the program name (argv[0]);
- $# is the number of arguments.
- $* is an arry of arguments, not including argv[0]
- Take a quick look at foo.sh
- The system function
- stdlib.h
- int system(const char *command);