WRITE_PROCESS
Use the WRITE_PROCESS script function to write the content of a data sequence to a file. WRITE_PROCESS exports the content of any data sequence to a text file. You must specify a reference to the corresponding data sequence, which is stored when you create the data sequence in a script variable. Each line of the data sequence is a line in the file. You can define whether you want all or only a specific column of the data sequence written to the file.
Syntax
WRITE_PROCESS (Data-Sequence Reference, File, Agent, Login, [Mode], [CodeTable], [File Attributes], [Column])
WRITE_PROCESS (Data-Sequence Reference, File, Agent, Login, [Mode], [CodeTable], [File Attributes], [ALL], [Delimiter])
Parameters
| Parameter | Description | Format / Allowed Values |
|---|---|---|
| Data-Sequence Reference | Reference to the data sequence whose content should be exported to a file. | Script variable |
| File | Path and the name of the file. | Script variable or script literal |
| Agent | Name of the agent whose host should be used to store the file. | AE name, script variable or script literal |
| Login | Name of the Login object that is used for logging on to the host of the specified agent. | AE name, script variable or script literal |
| Mode |
(Optional) Defines the further procedure if the specified file already exists:
|
AE name, script variable or script literal |
| CodeTable |
(Optional) Name of a Code Table object that should be used for coding the file. For example, <ISO-8859-15> or <UTF-8>. The default CodeTable is the one that is defined in the Agent's INI file. |
AE name, script variable or script literal |
| File Attributes |
(Optional) Additional file attributes for the generated file. Use commas to separate attributes if you define multiple attributes. |
Script variable or script literal |
| Column |
(Optional) The number of the column(s) of the data sequence that should be written to the file:
|
Script literal, script variable, or a number without quotation marks |
| Delimiter | (Optional) The character that should be used if you define several columns. This parameter is only relevant if you export all columns. | Script literal, script variable, or a number without quotation marks |
Return Codes
- 0: The file has successfully been exported.
- 20554: The agent is currently not active.
Examples
The following example creates a data sequence that stores a list of the file names of a particular directory. Then, the content of this data sequence is stored in a file on a different host. If an error occurs (return code of WRITE_PROCESS > 0), an error message is written and sent to the responsible AE user:
:SET &HND# = PREP_PROCESS_FILENAME("WIN01","c:\AUTOMIC\server\bin\*.exe",,,,"COL=DELIMITER","DELIMITER=*\*")
:SET &RET# = WRITE_PROCESS(&HND#,"C:\temp\export.txt",WIN02, LOGIN.GLOBAL,OVERWRITE)
:IF &RET# > 0
:SET &ERRNR# = SYS_LAST_ERR_NR()
:SET &ERRINS# = SYS_LAST_ERR_INS()
:SET &MESSAGE# = GET_MSG_TXT(&ERRNR#,&ERRINS#)
:SEND_MSG &$USER#, &$DEPARTMENT#, &MESSAGE#
:ENDIF
The next example defines UTF-8 in the CodeTable parameter so that a smiley can be interpreted and written to a file:
:SET &LINE1# = "Hello Test ☺"
:SET &RET# = PUT_PROCESS_LINE(&HND#, &LINE1#, ",")
:SET &RET# = WRITE_PROCESS(&HND#,"C:\temp\write_process_utf8.txt",WIN04, LOGIN.WINDOWS,OVERWRITE,"<UTF-8>")
:IF &RET# > 0
:SET &ERRNR# = SYS_LAST_ERR_NR()
:SET &ERRINS# = SYS_LAST_ERR_INS()
:SET &MESSAGE# = GET_MSG_TXT(&ERRNR#,&ERRINS#)
:SEND_MSG &$USER#, &$DEPARTMENT#, &MESSAGE#
:ENDIF
See also: