---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# LSOFParser - Global

# LSOFParser - Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The LSOFParser script include provides methods to parse the output of the lsof command: `lsof -i4TCP -n -P -F pcnfT`.

Use this script include with a discovery script when you need to parse lsof output.

## LSOFParser - error(String msg) {#ariaid-title2}

Generates the specified error message.
{#r_LSOFP-error_S__table_s4s_td2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| msg | String | The error message |
[Table 1. Parameters]

{#r_LSOFP-error_S__table_s4s_td2_5t} {#r_LSOFP-error_S__table_t4s_td2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 2. Returns]

{#r_LSOFP-error_S__table_t4s_td2_5t}

## LSOFParser - initFileDescriptor() {#ariaid-title3}

Initializes the file descriptor process.
{#r_LSOFP-initFileDescriptor__table_j5f_kd2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#r_LSOFP-initFileDescriptor__table_j5f_kd2_5t} {#r_LSOFP-initFileDescriptor__table_k5f_kd2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 4. Returns]

{#r_LSOFP-initFileDescriptor__table_k5f_kd2_5t}

## LSOFParser - initProcess() {#ariaid-title4}

Initializes the parser process.
{#r_LSOFP-initProcess__table_omf_cd2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#r_LSOFP-initProcess__table_omf_cd2_5t} {#r_LSOFP-initProcess__table_pmf_cd2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 6. Returns]

{#r_LSOFP-initProcess__table_pmf_cd2_5t}

## LSOFParser - on_c(String line) {#ariaid-title5}

Sets the current command.
{#r_LSOFP-on_c_S__table_wqf_fb2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| line | String | The command |
[Table 7. Parameters]

{#r_LSOFP-on_c_S__table_wqf_fb2_5t} {#r_LSOFP-on_c_S__table_xqf_fb2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 8. Returns]

{#r_LSOFP-on_c_S__table_xqf_fb2_5t}

## LSOFParser - on_endFileDescriptor() {#ariaid-title6}

Closes the file descriptor process.
{#r_LSOFP-on_endFileDescriptor__table_eqx_nc2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 9. Parameters]

{#r_LSOFP-on_endFileDescriptor__table_eqx_nc2_5t} {#r_LSOFP-on_endFileDescriptor__table_fqx_nc2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 10. Returns]

{#r_LSOFP-on_endFileDescriptor__table_fqx_nc2_5t}

## LSOFParser - on_endProcess() {#ariaid-title7}

Closes the parser process.
{#r_LSOFP-on_endProcess__table_ogc_vc2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 11. Parameters]

{#r_LSOFP-on_endProcess__table_ogc_vc2_5t} {#r_LSOFP-on_endProcess__table_pgc_vc2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 12. Returns]

{#r_LSOFP-on_endProcess__table_pgc_vc2_5t}

## LSOFParser - on_f(String line) {#ariaid-title8}

Sets the current file descriptor.
{#r_LSOFP-on_f_S__table_ywq_nb2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| line | String | The file descriptor |
[Table 13. Parameters]

{#r_LSOFP-on_f_S__table_ywq_nb2_5t} {#r_LSOFP-on_f_S__table_zwq_nb2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 14. Returns]

{#r_LSOFP-on_f_S__table_zwq_nb2_5t}

## LSOFParser - on_n(String line) {#ariaid-title9}

Sets the current address.
{#r_LSOFP-on_n_S__table_lx3_vb2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| line | String | The address |
[Table 15. Parameters]

{#r_LSOFP-on_n_S__table_lx3_vb2_5t} {#r_LSOFP-on_n_S__table_mx3_vb2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 16. Returns]

{#r_LSOFP-on_n_S__table_mx3_vb2_5t}

## LSOFParser - on_p(String line) {#ariaid-title10}

Sets the current PID.
{#r_LSOFP-on_p_S__table_sm5_v12_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| line | String | The PID |
[Table 17. Parameters]

{#r_LSOFP-on_p_S__table_sm5_v12_5t} {#r_LSOFP-on_p_S__table_tm5_v12_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 18. Returns]

{#r_LSOFP-on_p_S__table_tm5_v12_5t}

## LSOFParser - on_T(String line) {#ariaid-title11}

Sets the current state.
{#r_LSOFP-on_T_S__table_x2h_fc2_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| line | String | The state |
[Table 19. Parameters]

{#r_LSOFP-on_T_S__table_x2h_fc2_5t} {#r_LSOFP-on_T_S__table_y2h_fc2_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 20. Returns]

{#r_LSOFP-on_T_S__table_y2h_fc2_5t}

## LSOFParser - parse(String lsofOutput) {#ariaid-title12}

Parses the specified `lsof` output.
Results are available in connections and listeners arrays, and errors are recorded in
errorString() and isValid().
{#r_LSOFP-parse_S__table_lbn_g12_5t__entry__3}

| Name | Type | Description |
|-|-|-|
| lsofOutput | String | The `lsof` output |
[Table 21. Parameters]

{#r_LSOFP-parse_S__table_lbn_g12_5t} {#r_LSOFP-parse_S__table_mbn_g12_5t__entry__2}

| Type | Description |
|-|-|
| void |   |
[Table 22. Returns]

{#r_LSOFP-parse_S__table_mbn_g12_5t}

