Skip to content

Command reference

Syntax

stcpren [options] <file>                         # processes one file
stcpren [options] -scan <directory>              # scans a directory
stcpren -ini <rules.ini> -rules <rules.json>     # converts INI rules to JSON
stcpren -db -rules <routing> -export <target>    # exports a routing from the database

Options come before the file name. You must give a file, the -scan option, the -ini option or the -export option; otherwise the command shows the help and exits with code 2. With -scan "", the directory is the one given in ScanDir in the routing.

Configuration and rules

OptionTypeDefaultDescription
-configtext/usr/local/stcpren/configs/config.jsonConfiguration file.
-dbbooleanfalseReads the routing from the configuration database.
-rulestext—With -db, routing name. Without -db, path to the routing JSON file. With -ini, generated JSON file.
-initext—INI rule file to convert to JSON.
-exporttext—With -db, writes the routing to JSON. If the target is a directory, the file is named after the routing with the .json extension.
-testbooleanfalseShows the rule that would be applied to each file, without processing it.

Scan

OptionTypeDefaultDescription
-scantext—Scan directory. Replaces ScanDir.
-nosubdirbooleanfalseThe given directory only.
-subdirbooleanfalseSubdirectories only.
-subdir2booleanfalseThe directory and its subdirectories.
-dirregex, -dirregexnegtext—Expressions that include or exclude directories.
-fileregex, -fileregexnegtext—Expressions that include or exclude files.
-firstruleinteger0Number of the first rule evaluated.
-scansemnametext—Scan semaphore name.
-scansemtimeoutinteger-1Maximum wait for the semaphore, in milliseconds.
-scansemoptionsinteger0Semaphore options. 1: exits if the semaphore is in use.

The scan options replace the corresponding routing values. See Rule reference.

File data

OptionTypeDefaultDescription
-srctext—File source, compared with SrcRegEx.
-dsttext—File destination, available in $DSTUSER when no rule is applied.
-filekeytext—File key, available in $FILEKEY.
-copydirtext—Copy directory. Replaces CopyToDir.
-backupdirtext—Backup directory. Replaces BkpToDir.
-var0 to -var9text—Values of the $VAR0 to $VAR9 variables and of the fixed-value replacement items. See Variable reference.

Run and log

OptionTypeDefaultDescription
-langtextptbMessage language: ptb (Portuguese), enu (English) or esp (Spanish).
-langfiletext/usr/local/stcpren/configs/messages.jsonMessage file.
-pidtext—PID file. Replaces applPidFile.
-errfiletext—Redirects standard error (stderr) to a file.
-nologevent, -nologroutebooleanfalseKept for compatibility. No effect in this version.
-vbooleanfalseShows the version and exits.

Exit codes

CodeMeaning
0Run completed. In a scan, errors in individual files are recorded in the log and do not change the code.
1Failure processing the file, or reading the configuration or the routing. It is also the -v code.
2Invalid usage: the file or the -scan, -ini or -export option is missing.
4Startup failure, for example in the license, the configuration database or the log.

Examples

# Processes a file received from PARTNER
stcpren -db -rules INBOUND -src PARTNER /mailbox/IN/NOTES.TXT

# Scans the directory and its subdirectories, .TXT files only
stcpren -db -rules INBOUND -scan /mailbox/IN -subdir2 -fileregex '\.TXT$'

# Shows the rule applied to each file, without processing
stcpren -db -rules INBOUND -scan /mailbox/IN -test

# Uses a routing in a local file
stcpren -rules /usr/local/stcpren/configs/inbound.json /mailbox/IN/NOTES.TXT

# Exports a routing from the database
stcpren -db -rules INBOUND -export /tmp