{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1057,"path":"api-reference/server-api-reference/c_LSOFParserAPI.md","title":null,"bundle":null,"doc_type":null,"release":null,"body":"---\ntitle: LSOFParser - Global\ndescription: The LSOFParser script include provides methods to parse the output of the lsof command: lsof -i4TCP -n -P -F pcnfT.Generates the specified error message.Initializes the file descriptor process.Initializes the parser process.Sets the current command.Closes the file descriptor process.Closes the parser process.Sets the current file descriptor.Sets the current address.Sets the current PID.Sets the current state.Parses the specified lsof output.\nlocale: en-US\ncanonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/c\\_LSOFParserAPI.html\nrelease: australia\nproduct: Server API Reference\nclassification: server-api-reference\ntopic_type: concept\nlast_updated: \"2026-03-12\"\nreading_time_minutes: 1\nbreadcrumb: [Server API reference, API reference, API implementation and reference]\n---\n\n# LSOFParser- Global\n\nThe LSOFParser script include provides methods to parse the output of the `lsof` command: `lsof -i4TCP -n -P -F pcnfT`.\n\nUse this script include with a discovery script when you need to parse `lsof` output.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## LSOFParser - error\\(String msg\\)\n\nGenerates the specified error message.\n\n|Name|Type|Description|\n|----|----|-----------|\n|msg|String|The error message|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - initFileDescriptor\\(\\)\n\nInitializes the file descriptor process.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - initProcess\\(\\)\n\nInitializes the parser process.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_c\\(String line\\)\n\nSets the current command.\n\n|Name|Type|Description|\n|----|----|-----------|\n|line|String|The command|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_endFileDescriptor\\(\\)\n\nCloses the file descriptor process.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_endProcess\\(\\)\n\nCloses the parser process.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_f\\(String line\\)\n\nSets the current file descriptor.\n\n|Name|Type|Description|\n|----|----|-----------|\n|line|String|The file descriptor|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_n\\(String line\\)\n\nSets the current address.\n\n|Name|Type|Description|\n|----|----|-----------|\n|line|String|The address|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_p\\(String line\\)\n\nSets the current PID.\n\n|Name|Type|Description|\n|----|----|-----------|\n|line|String|The PID|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - on\\_T\\(String line\\)\n\nSets the current state.\n\n|Name|Type|Description|\n|----|----|-----------|\n|line|String|The state|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n## LSOFParser - parse\\(String lsofOutput\\)\n\nParses the specified `lsof` output.\n\nResults are available in connections and listeners arrays, and errors are recorded in errorString\\(\\) and isValid\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|lsofOutput|String|The `lsof` output|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n"}}