1 local lp
= require("socket.lp")
4 print('\nUsage: lua lpr.lua [filename] [keyword=val...]\n')
5 print('Valid keywords are :')
7 ' host=remote host or IP address (default "localhost")\n' ..
8 ' queue=remote queue or printer name (default "printer")\n' ..
9 ' port=remote port number (default 515)\n' ..
10 ' user=sending user name\n' ..
11 ' format=["binary" | "text" | "ps" | "pr" | "fortran"] (default "binary")\n' ..
12 ' banner=true|false\n' ..
13 ' indent=number of columns to indent\n' ..
14 ' mail=email of address to notify when print is complete\n' ..
15 ' title=title to use for "pr" format\n' ..
16 ' width=width for "text" or "pr" formats\n' ..
20 ' localbind=true|false\n'
25 if not arg
or not arg
[1] then
31 local pat
= "[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)"
33 string.gsub(arg
[i
], pat
, function(name
, value
) opt
[name
] = value
end)
38 if arg
[1] ~= "query" then
41 io
.stdout
:write(tostring(r
or e
),'\n')
44 io
.stdout
:write(tostring(r
or e
), '\n')
49 --lua lp.lua lp.lua queue=default host=localhost
50 --lua lp.lua lp.lua queue=default host=localhost format=binary localbind=1
51 --lua lp.lua query queue=default host=localhost