Use input files for piconfig commands
- Last UpdatedJan 13, 2023
- 3 minute read
- PI System
- PI Server
Entering commands by hand in interactive sessions is prone to errors. An easier approach is to enter the commands in a text file, save it, and then use that file as input to later piconfig sessions. This is particularly useful for maintaining the point database using a spreadsheet.
Note: For better readability, you can add comments to the text file.
Prepare input files
For example, suppose you want to list points with names starting in and , including tagname, pointsource, and pointtype. You could specify delimited output structure.
To do this, you could prepare and save an ASCII file named list.inp:
* list.inp *
* This piconfig script file lists the tagname, pointsource,
* and pointtype for all tags that start with "S" and
* that have point source R
*
@table pipoint
@mode list
@stype delimited
@ostructure tag, pointsource, pointtype
@select tag=s*, pointsource=R
@endsection
Start piconfig and run this input file using the input command:
$ piconfig
4 (Ls - ) piconfig> @input list.inp
The following output is generated:
SINUSOID,Float32,R
SINUSOIDU,Float32,R
SQF100,Float32,R
SQF101,Float32,R
4 (Ls - PIPOINT) piconfig>
Pass an input file as a parameter
An alternative is to pass the input file as a parameter on the command line. The piconfig utility takes each pair of input parameters and treats the first as a command and the second as the command parameter:
$ piconfig input list.inp
SINUSOID,Float32,R
SINUSOIDU,Float32,R
SQF100,Float32,R
SQF101,Float32,R
4 (Ls - PIPOINT) piconfig>
Redirect an input file
Use the standard redirection from the command line:
$ piconfig < list.inp
SINUSOID,Float32,R
SINUSOIDU,Float32,R
SQF100,Float32,R
SQF101,Float32,R
piconfig 0 Data lines
6 Command lines
0 Records in error...
4 Records Listed
Input files may contain all data, all commands, or mixed commands and data. Input files may be nested; that is, an input file can refer to other input files.
Capture output and errors in files
The piconfig utility output and errors are displayed by default on the computer screen. Use the output and error commands to redirect this output in a file.
$ piconfig
*>@output list.out
*>@error errors.out
By default, piconfig echoes the input commands and input data in the file, as well as the output data. If you wish to see only the output data in the file, use the echo command with the data option:
*> @echo data
Pass commands as parameters
You can pass the commands on the piconfig command line. With each pair of input parameters, piconfig treats the first as a command and the second as the command parameter:
$ piconfig output list.out input list.inp
Redirect output
Use standard redirection from the command line:
$ piconfig < list.inp > list.out
Reuse an output file as an input file
Redirecting the output to a file is very useful because you can reuse the output file as an input file with other piconfig commands. For example, suppose you want to create a tag that is similar to another tag that already exists on the Data Archive server. For example, the tagname and the hardware address are the only differences; the descriptor, zero, span, pointtype, pointsource, and engineering units are the same.
To reuse an output file as an input file, list all of the point attributes of the existing tag to a file. Then use a text editor to modify the tag name and hardware address. Use the file as input to piconfig to create the new tag.