Configure a Script as Job Output¶
Instead of outputting a job to a printer, you can execute a script. For example, this can be a script for copying the spool file to the file system or for sending the spool file via e-mail.
The printer configuration is kept in the database. For the available printer configuration keys, refer to Printer Keys.
Usually, easyPRIMA is used for changing the printer configuration. For more information, refer to the easyPRIMA documentation. Alternatively, the printer configuration can be exported, imported and changed via PLOSSYS CLI.
This is how you specify a script as job output:
-
Specify
command://in theconnectionprinter key. -
Add the
commandsection. -
In
command, specify the name of the command or script withcmd. -
Specify the script or command parameters with
args. ThefileNameparameter is required and contains the name of the spool file. Additionally, you can pass any printer parameter (printer.xxx) and job parameter (job.xxx) to the script. The parameters have to be enclosed in double curly brackets{.Example - copies
{{job.current.copies}} -
Optionally, specify the return codes of the script to be interpreted as success. By default,
0is interpreted as success.
Example - printer connection with command calling a bash script
- printer: printercmd
connection: 'command://'
server: spooler1
command:
cmd: /code/bin/testout.sh
args:
- -printer
- '{{printer.printer}}'
- -file
- '{{fileName}}'
- -copies
- '{{job.current.copies}}'
expectedExitCodes:
- 2
- 0
Example - printer connection with command calling a PowerShell script
- printer: printercmd
connection: 'command://'
server: spooler1
command:
cmd: powershell
args:
- -Command
- C:\\mynicefolder\\myniceps.ps1
- -printer
- '{{printer.printer}}'
- -file
- '{{fileName}}'
- -copies
- '{{job.current.copies}}'
expectedExitCodes:
- 2
- 0
With the following command, the call of the PowerShell script above can be checked:
write "There are a total of $($args.count) arguments" | Out-File C:\tmp\out.txt
for ( $i = 0; $i -lt $args.count; $i++ ) {
write "Argument $i is $($args[$i])" | Out-File C:\tmp\out.txt -Append
}