Fortinet white logo
Fortinet white logo

Script Reference Guide

File_open(path, str)

File_open(path, str)

Opens a file, returns a file object.

Syntax

File_open(path, str);

Arguments

Name Description

str

A string which specifies the method to open the file.

path

A string which specifies the file path.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
filepath = "/etc/resolv.conf";
fp = file_open(filepath,"r");
if not fp then
debug("file open failed\n");
end
repeat
line = file_gets(fp, 256);
if line then
debug("line %s", line);
end
until not line
file_close(fp);
}

Supported Version

FortiADC version 5.2.x and later.

File_open(path, str)

File_open(path, str)

Opens a file, returns a file object.

Syntax

File_open(path, str);

Arguments

Name Description

str

A string which specifies the method to open the file.

path

A string which specifies the file path.

Events

Applicable in all events.

Example

when HTTP_REQUEST {
filepath = "/etc/resolv.conf";
fp = file_open(filepath,"r");
if not fp then
debug("file open failed\n");
end
repeat
line = file_gets(fp, 256);
if line then
debug("line %s", line);
end
until not line
file_close(fp);
}

Supported Version

FortiADC version 5.2.x and later.