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 databaseOptions 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
| Option | Type | Default | Description |
|---|---|---|---|
-config | text | /usr/local/stcpren/configs/config.json | Configuration file. |
-db | boolean | false | Reads the routing from the configuration database. |
-rules | text | — | With -db, routing name. Without -db, path to the routing JSON file. With -ini, generated JSON file. |
-ini | text | — | INI rule file to convert to JSON. |
-export | text | — | With -db, writes the routing to JSON. If the target is a directory, the file is named after the routing with the .json extension. |
-test | boolean | false | Shows the rule that would be applied to each file, without processing it. |
Scan
| Option | Type | Default | Description |
|---|---|---|---|
-scan | text | — | Scan directory. Replaces ScanDir. |
-nosubdir | boolean | false | The given directory only. |
-subdir | boolean | false | Subdirectories only. |
-subdir2 | boolean | false | The directory and its subdirectories. |
-dirregex, -dirregexneg | text | — | Expressions that include or exclude directories. |
-fileregex, -fileregexneg | text | — | Expressions that include or exclude files. |
-firstrule | integer | 0 | Number of the first rule evaluated. |
-scansemname | text | — | Scan semaphore name. |
-scansemtimeout | integer | -1 | Maximum wait for the semaphore, in milliseconds. |
-scansemoptions | integer | 0 | Semaphore options. 1: exits if the semaphore is in use. |
The scan options replace the corresponding routing values. See Rule reference.
File data
| Option | Type | Default | Description |
|---|---|---|---|
-src | text | — | File source, compared with SrcRegEx. |
-dst | text | — | File destination, available in $DSTUSER when no rule is applied. |
-filekey | text | — | File key, available in $FILEKEY. |
-copydir | text | — | Copy directory. Replaces CopyToDir. |
-backupdir | text | — | Backup directory. Replaces BkpToDir. |
-var0 to -var9 | text | — | Values of the $VAR0 to $VAR9 variables and of the fixed-value replacement items. See Variable reference. |
Run and log
| Option | Type | Default | Description |
|---|---|---|---|
-lang | text | ptb | Message language: ptb (Portuguese), enu (English) or esp (Spanish). |
-langfile | text | /usr/local/stcpren/configs/messages.json | Message file. |
-pid | text | — | PID file. Replaces applPidFile. |
-errfile | text | — | Redirects standard error (stderr) to a file. |
-nologevent, -nologroute | boolean | false | Kept for compatibility. No effect in this version. |
-v | boolean | false | Shows the version and exits. |
Exit codes
| Code | Meaning |
|---|---|
0 | Run completed. In a scan, errors in individual files are recorded in the log and do not change the code. |
1 | Failure processing the file, or reading the configuration or the routing. It is also the -v code. |
2 | Invalid usage: the file or the -scan, -ini or -export option is missing. |
4 | Startup 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