我想用不同的设置在Ubuntu18.04(gnome)中创建一个我的打印机副本。我相信这是可行的16.04(鹦鹉螺),但我现在找不到任何方法。

有人知道吗?

谢谢, 研发

最佳回复

很简单!只需将浏览器导航到CUPS管理页面, http://localhost:631 并添加具有新名称和特性但设备URI相同的打印机。我有一个bash脚本和几个别名,可以帮助我处理多个CUPS队列:

[email protected]:~(0)$ alias lpqa
alias lpqa='for i in $( lpstat -a | cut -f1 "-d " ) ; do  lpq -P $i; done'
[email protected]:~(0)$ alias lpqac
alias lpqac='for i in $( lpstat -a | cut -f1 "-d " ) ; do  lpq -P $i| egrep -v "no entries" | $HOME/bin/rcg "is not ready" BRIGHT_RED "is ready" BRIGHT_GREEN; done'

~/bin/cups开关:

#!/bin/bash
# Walt Sullivan, Walt Sullivan Software, Ltd.

# determine my name
me=
me=${me##*/}

declare -i debug=0
declare -i verbose=0

# -h or --help 
help () {
    cat <<EOF
${me} [-h|--help] [-v|--verbose] newqueue
${me}: Tell CUPS to disable the current  print queue and enable newqueue.
EOF
    exit 2
}

# from /usr/share/doc/util-linux/examples/getopt-parse.bash 2015-Sep-06
# # Note that we use `"[email protected]"' to let each command-line parameter expand to a 
# # separate word. The quotes around `[email protected]' are essential!
# # We need TEMP as the `eval set --' would nuke the return value of getopt.

TEMP=`getopt -o dhv --long debug,help,verbose \
     -n 'cupsswitch.bash' -- "[email protected]"`

if [[ $? != 0 ]] ; then echo "${me} --help for help." >&2 ; exit 1 ; fi

# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"

while true ; do
    case "" in
        -d|--debug) debug=1; shift;;
        -h|--help) help; shift;;
        -v|--verbose) verbose=1; shift;;
        --) shift; break;;
        *) echo "Internal error! ${me} --help for help";exit 1;;
    esac
done
if [[ $# -ne 1  ]] ; then
    help
fi

newqueue=""

lpstat -p | egrep -q "^printer $newqueue " 
if [[ ${PIPESTATUS[1]} != 0 ]] ; then
    echo "Cannot switch to $newqueue - not a printer" >&2
    exit 3
fi


for p in $(lpstat -p | grep enabled | awk '{print }') ; do
    [[ $verbose -ne 0 ]] && printf "Disabling $p\n"
    cupsdisable $p
done

[[ $verbose -ne 0 ]] && printf "Enabling $newqueue\n"
cupsenable $newqueue

[[ $verbose != 0 ]] && lpstat -p | egrep -B1 "ready to print" 
[[ $verbose != 0 ]] && lpstat -p | egrep "is idle"
exit 0

为了 rcg: Regex Colored Glasses 请参阅O'Reilly Linux服务器黑客手册,或 https://stackoverflow.com/questions/981601/colorized-grep-viewing-the-entire-file-with-highlighted-matches/1056786#1056786