目录
此附录概括了命令行工具并伴随着PaperCut NG高级的程序设计工具。使用这些工具已经在此指南里讨论过,然而这提供了一个这些工具的参考指导和他们的使用。
PaperCut NG提供了非常强大的高级工具和对所有定制行为提供加强的机会。然而,如果使用不正确,这些工具可能导致未预期的结果。许多高级的工具写入软件并得以开发。期望试图使用高级的工具的读者以适应所使用的命令提示,并且开发系统管理和服务器监控的程序。
server-command工具提供了许多对服务器操作的访问,其中包括对用户的管理,系统的维护,帐户的处理和打印机的控制。server-command工具通过命令行command-line或脚本的自动操作对于PaperCut NG应用程序服务器来说是一个理想的选择。
一些管理员如何选择使用server-command工具的例子:
联机备份和数据快照的日程安排。
用户和/或组同步任务的日程安排。
在帐户被添加到网络之后自动增加新的用户。
执行帐户交易如:添加资金/配额到用户帐户。
使用定制的脚本自动创建用户帐户。
禁用/激活打印机。
禁用/激活用户的打印。
控制用户的限制级。
管理共享帐户
server-command程序是命令行command-line工具。它接受命令作为参数并输出控制台的命令结果(标准的输出)。对于安全方面的问题仅用户可以读取访问server.properties (正常情况下是仅Administrators 组)并有权执行此命令。
有关Windows系统典型的使用:
增加$10.00到用户命名的'testuser':
C:\> cd [app-dir]\server\bin\win
C:\> server-command adjust-user-account-balance "testuser" 10.00 \
"Added $10.00 to your account"
注意:反斜线表明了文本应该在同一行上。
通过server-command --help列出所有可利用的命令:
Usage: server-command COMMAND [ARGS...]
COMMAND : The server command name.
ARGS : A list of arguments to supply to the command.
COMMANDS:
user-exists <username>
Test to see if a user exists.
<username> - the username to test.
get-user-account-balance <username>
Get a user's current account balance.
<username> - the user's username.
get-user-property <username> <property>
Gets a user property.
<username> - the name of the user.
<property> - the name of the property to get. Valid properties include:
balance - the user's current account balance
card-number - the user's card number
card-pin - the user's card pin number
department - the user's department
disabled-net - whether or not the user's internet access is
currently disabled
disabled-print - whether or not the user's printing is currently
disabled
email - the user's email
full-name - the user's full name
notes - notes for the user
office - the user's office
print-stats.job-count - the total print job count for the user
print-stats.page-count - the total printed page count for the user
restricted - whether or not the user is currently restricted
set-user-property <username> <property> <value>
Sets a user property.
<username> - the name of the user.
<property> - the name of the property to set. Valid properties and
values include:
balance - the user's current account balance (a decimal number)
card-number - the user's card number (any text)
card-pin - the user's card pin number (any text)
department - the user's department (any text)
disabled-net - whether or not the user's internet access is
currently disabled (TRUE or FALSE)
disabled-print - whether or not the user's printing is currently
disabled (TRUE or FALSE)
email - the user's email (an email address, or any text)
full-name - the user's full name (any text)
notes - notes for the user (any text)
office - the user's office (any text)
password - the user's password (for internal users only) (any text)
restricted - whether or not the user is currently restricted
(TRUE or FALSE)
<value> - the value to set (see <property> for valid values).
adjust-user-account-balance <username> <adjustment> <comment>
Adjust a user's account balance.
<username> - the user's username.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<comment> - a comment to be associated with the transaction.
adjust-user-account-balance-if-available <username> <adjustment> <comment>
Adjust a user's account balance if there is enough credit available.
<username> - the user's username.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<comment> - a comment to be associated with the transaction.
adjust-user-account-balance-if-available-leave-remaining \
<username> <adjustment> <leave-remaining> <comment>
Adjust a user's account balance if there is enough credit available
to leave the given amount available in the account.
<username> - the user's username.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<leave-remaining> - the amount to leave in the account.
<comment> - a comment to be associated with the transaction.
adjust-user-account-balance-by-group <group> <adjustment> <comment>
Adjust the account balance for all users in a group. This process
happens in the background.
<group> - the group for which all users' accounts are to be adjusted.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<comment> - a comment to be associated with the transaction.
adjust-user-account-balance-by-group-up-to <group> <adjustment> <limit>
<comment>
Adjust the account balance for all users in a group, but don't increase
user balance beyond the given limit. This process happens in the
background.
<group> - the group for which all users' accounts are to be adjusted.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<limit> - don't increase user balance beyond this limit.
<comment> - a comment to be associated with the transaction.
set-user-account-balance <username> <balance> <comment>
Set a user's account balance to a set value.
<username> - the user's username.
<balance> - set the account to this value. +ve or -ve.
<comment> - a comment to be associated with the transaction.
set-user-account-balance-by-group <group> <balance> <comment>
Set the balance for each member of a group to the given value. This
process happens in the background.
<group> - the group for which all users' balance is to be set.
<balance> - the value to set all users' balance to. +ve or -ve.
<comment> - a comment to be associated with the transaction.
reset-user-counts <username> <reset_by>
Reset the page and job counts associated with a user.
<username> - the user's username.
<reset_by> - name of the user/script/process resetting the counts.
re-apply-initial-user-settings <username>
Re-applies initial settings on the user. Initial user settings are based on group membership.
<username> - the user's username.
disable-printing-for-user <username> <minutes_disabled>
Disable printing for a user for a set period of time.
<username> - the name of the user to disable printing for.
<minutes_disabled> - the time in minutes to disable. -1 indicates
forever.
add-new-user <username>
Trigger the process of adding a new user account. Assuming the user
exists in the OS/Network/Domain user directory, the account will be
created with the correct initial settings as defined by the rules
set up in the admin interface under the Groups section.
<username> - the user's system username.
rename-user <current_username> <new_username>
Rename the given existing user. Use this method with care. Renaming a
user should be performed in conjunction with renaming the user in the
OS/Network/Domain.
<current_username> - the name of the user to rename.
<new_username> - the user's new name.
delete-existing-user <username>
Delete a user account from the system. Use this method with care.
Calling this will perminantly delete the user account from the user
list (print history records remain).
<username> - the user's system username.
list-user-accounts
List the names of all the user accounts in the system, sorted by
username, one per line.
list-shared-accounts
List the names of all the shared accounts in the system, sorted by
shared account name, one per line.
list-user-shared-accounts <username>
List the names of all the shared accounts accessible by the given user
sorted by account name, one per line.
shared-account-exists <account_name>
Test to see if a shared account exists.
<account_name> - the shared account name to test.
get-shared-account-account-balance <account_name>
Get shared account's current account balance.
<account_name> - the shared acount's full name.
get-shared-account-property <account_name> <property>
Gets a shared account property.
<account_name> - the name of the user.
<property> - the name of the property to get. Valid properties include:
access-groups - the shared account's access groups)
(a comma separated list)
access-users - the shared account's access users
(a comma separated list)
balance - the shared account's current balance
comment-option - the shared account's commenting option
disabled - whether or not the shared account is currently disabled
invoice-option - the shared account's invoicing option
notes - notes for the shared account
pin - the shared account's PIN
restricted - whether or not the shared account is currently
restricted
set-shared-account-property <account_name> <property> <value>
Sets a shared account property.
<account_name> - the name of the shared account.
<property> - the name of the property to set. Valid properties and
values include:
access-groups - the shared account's access groups)
(a comma separated list)
access-users - the shared account's access users
(a comma separated list)
balance - the shared account's current balance (a decimal number)
comment-option - the shared account's commenting option. One of:
NO_COMMENT - no comment may be entered
COMMENT_REQUIRED - a comment must be entered
COMMENT_OPTIONAL - the user may enter a comment or not
disabled - whether or not the shared account is currently disabled
(TRUE or FALSE)
invoice-option - the shared account's invoicing option. One of:
ALWAYS_INVOICE - print jobs will always be invoiced
NEVER_INVOICE - print jobs will never be invoiced
USER_CHOICE_ON - the user can choose (default on/yes)
USER_CHOICE_OFF - the user can choose (default off/no)
notes - notes for the shared account (any text)
pin - the shared account's PIN (any text, must be unique)
restricted - whether or not the shared account is currently
restricted (TRUE or FALSE)
<value> - the value to set (see <property> for valid values).
adjust-shared-account-account-balance <account_name> <adjustment> <comment>
Adjust a shared account's account balance.
<account_name> - the shared account's full name.
<adjustment> - the adjustment amount as a number. +ve or -ve.
<comment> - a comment to be associated with the transaction.
set-shared-account-account-balance <account_name> <balance> <comment>
Set a shared account's balance to a set value.
<account_name> - the shared account's full name.
<balance> - set the account to this value. +ve or -ve.
<comment> - a comment to be associated with the transaction.
add-new-shared-account <shared_account_name>
Add a new shared account.
<shared_account_name> - the name of the shared account.
delete-existing-shared-account <shared_account_name>
Delete a shared account from the system. Use this method with care.
Calling this will permanently delete it from the shared account list
(print history records will remain).
<shared_account_name> - the name of the shared account to delete.
add-shared-account-access-user <shared_account_name> <username>
Allow the given user access to the given shared account without using
a pin.
<shared_account_name> - the name of the shared account to allow access
to.
<username> - the name of the user to give access to.
add-shared-account-access-group <shared_account_name> <group_name>
Allow the given group access to the given shared account without using
a pin.
<shared_account_name> - the name of the shared account to allow access
to.
<group_name> - the name of the group to give access to.
remove-shared-account-access-user <shared_account_name> <username>
Revoke the given user'- access to the given shared account.
<shared_account_name> - the name of the shared account to revoke access
to.
<username> - the name of the user to revoke access for.
remove-shared-account-access-group <shared_account_name> <group_name>
Revoke the given group's access to the given shared account.
<shared_account_name> - the name of the shared account to revoke access
to.
<group_name> - the name of the group to revoke access for.
get-printer-property <server_name> <printer_name> <property>
Gets a printer property.
<server_name> - the name of the server the printer is hosted on.
<printer_name> - the name of the printer.
<property> - the name of the property to get. Valid properties include:
disabled - whether or not the printer is currently disabled
print-stats.job-count - the total print job count for this printer
print-stats.page-count - the total printed page count for this printer
set-printer-property <server_name> <printer_name> <property> <value>
Sets a printer property.
<server_name> - the name of the server the printer is hosted on.
<printer_name> - the name of the printer.
<property> - the name of the property to set. Valid properties and
values include:
disabled - whether or not the user is currently disabled
(TRUE or FALSE)
<value> - the value to set (see <property> for valid values).
reset-printer-counts <server_name> <printer_name> <reset_by>
Reset the page and job counts associated with a printer.
<server_name> - the name of the server hosting the printer.
<printer_name> - the printer's name.
<reset_by> - name of the user/script/process resetting the counts.
disable-printer <server_name> <printer_name> <minutes_disabled>
Disable a printer for a set period of time.
<server_name> - the name of the server hosting the printer.
<printer_name> - the printer's name.
<minutes_disabled> - the time in minutes to disable. -1 indicates
forever.
use-card <user_name> <card_number>
Redeem a card and place the credit on the user's account.
<user_name> - the name of the user with the account to credit.
<card_number> - the number of the card to use.
perform-online-backup
Start an online backup. The back file is written to
~/server/data/backups. as a dated, zipped XML file. This process
happens in the background.
perform-group-sync
Start the process of synchronizing the system's group membership with
the OS/Network/Domain's group membership. This process happens in the
background.
perform-user-and-group-sync
Start a full user and group synchronization. This is equivalent to
pressing on the "Synchronize Now" button in the admin user interface.
The of the sync process, such as deleting old users, is
determined by the current system settings as defined in the admin
interface. This process happens in background.
perform-user-and-group-sync-advanced <delete_old_users> <update_details>
An advanced version of the user and group syncronization process
providing control over the sync This process will happen in
the background.
<delete_old_users> - set to TRUE remove old users, else FALSE.
<update_details> - set to TRUE if exist users details (e.g. email,
full-name, etc. ) are to be updated.
add-new-users
Calling this method will start a specialized user and group
synchronization process optimized for tracking down adding any new
users that exist in the OS/Network/Domain user directory and not in
the system. Any existing user accounts will not be modified. A group
syncronization will only be performed if new users are actually added
to the system.
is-task-complete
Returns TRUE if a long running task such as perform-group-sync,
perform-user-and-group-sync, or add-new-users has completed.
get-task-status
Returns status information such as progress, completion status and,
error messages, on the current or last run long running task such as
perform-group-sync, perform-user-and-group-sync, or add-new-users.
batch-import-shared-accounts <import_file> <test>
<delete_non_existent_accounts>
Import the shared accounts contained in the given tab-delimited import
file.
<import_file> - the import file location.
<test> - (TRUE or FALSE) If TRUE, perform a test only. The printed
statistics will show what would have occurred if testing
wasn't enabled. No accounts will be modified.
<delete_non_existent_accounts> - (TRUE or FALSE) If TRUE, accounts that
do not exist in the import file but exist in the
system will be deleted. If FALSE, they will be
ignored.
batch-import-internal-users <import_file> <overwrite_existing_passwords>
<overwrite_existing_pins>
Import the internal users contained in the given tab-delimited import
file. See the user manual chapter 'Advanced User Management' for a
description of the file format.
<import_file> - the import file location.
<overwrite_existing_passwords> (optional, default TRUE) - (TRUE or
FALSE) If TRUE, passwords from the import file will overwrite
existing passwords where a user already has a has a password set.
If FALSE, existing passwords will not be changed.
<overwrite_existing_pins> (optional, default TRUE) - (TRUE or FALSE) If
TRUE, PINs from the import file will overwrite existing PINs where
a user already has a has a PIN set. If FALSE, existing PINs will
not be changed.
batch-import-user-card-id-numbers <import_file> <overwrite_existing_pins>
Import the user card/ID numbers and PINs contained in the given
tab-delimited import file (see the chapter 'Advanced User Management'
in user manual for a description of the file format).
<import_file> - the import file location.
<overwrite_existing_pins> (optional, default TRUE) - (TRUE or FALSE) If
TRUE, PINs from the import file will overwrite existing PINs where
a user already has a has a PIN set. If FALSE, existing PINs will
not be changed.
create-user-client-accounts-file
Creates a file containing shared accounts data for the user client.
See the manual for more information on how this feature can be used.
The file will be saved on the server to the location:
[app-path]\server\data\client\client-accounts.dat
If this file already exists it will be over-written.
get-config <config-name>
Gets the value of the given config value printing the result.
If the config value does not exist, a blank string is displayed.
<config-name> - the name of the config value to get.
set-config <config-name> <config-value>
Sets the value of the give config item.
NOTE: Take care updating config values. You may cause serious
problems which can only be fixed by reinstallation of
the application. Use the set-config command at your own risk.
<config-name> - the name of the config value to set.
<config-value> - the value to set.
server-command是批文件理想的脚本。管理员希望使用诸如: C#, Java, Visual Basic, Perl or Python程序语言来控制PaperCut NG,但应该考虑 XML
Web Services 的API。所有命令可通过server-command工具或网络服务层被调用。
更多有关XML Web Services API的信息在 “XML Web Services API”章节里有描述。