fopen()
含义:Open a PSL channel to a file(打开一个PSL的管道指向某个文件)
Format
fopen(filename,mode,[shr=upd])
Parameters
Parameter | Definition |
filename | name of the file to which the PSL channel should be opened. |
mode | file access mode Valid Values |
shr=upd | literal switch used only with PATROL Agent for OpenVMS Use this switch to open a file so that another process can write to it. For more information, see the documentation for OpenVMS. Note: When creating a new file on OpenVMS, the default behavior is in effect; a file is created with a new version number. |
Description
The fopen() function opens a channel to filename that provides the access to filename from within a PSL process. The read(), readln(), write(), get_chan_info(),share(), fseek(), ftell(), and close() functions apply to channels that have been opened to files. When supported by the underlying operating system, the fopen() function performs security checks to determine whether the user name of the calling process has permission for the request. The valid range of mode is the same as for the ANSI C fopen() function.If the fopen() function is successful, it returns the PSL channel number to filename.A failure to open filename, such as an operating system problem or invalid mode, sets the PSL errno value and causes the fopen() function to return the NULL string without attempting to open the file. The fopen() function behaves much like the ANSI C fopen() function.
Example
Code:
readchan = fopen("/etc/passwd","r");
print("readchan number is: ",readchan,"\n");
Output: