cat()
Return the content of a file as a single text string.
Syntax
Parameters
Parameter | Definition |
---|---|
filename | name of the file whose contents are to be returned |
Description
The cat() function returns the contents of file filename as a single string or the NULL string on error. Newlines are preserved so that the foreach statement can be used to process the returned string as a list of the lines in filename.
The cat() function can return the following PSL errno values:
errno Value | Description |
---|---|
1 | E_PSL_CAT_MEMORY_FAILURE--memory allocation failure |
2 | E_PSL_CAT_READ_ERROR--read error |
29 | E_PSL_FILE_CANNOT_OPEN--could not open file |
30 | E_PSL_FILE_NOT_FOUND--file not found |
72 | E_PSL_FOPEN_BAD_ACCOUNT--insufficient file permissions |
Example
The following PSL statements list the users listed in the Unix system password file:
foreach person (people) {
name = ntharg(person, 1, ":");
print("name of person is:", name, "\n");
}