dispense - Coke machine interface
Synopsis
Diagnostics
Author
Copyright
Files
Bugs
Notes
dispense [[-c count] [ -u user] [drink|slot|drinks-only]]
dispense [-h] | [-R] | [-r slot] | [-s slot price [name]]
dispense door
dispense acct [user [[+|-|=] amount]] "reason"
dispense give "user amount"
dispense finger (coke|door [number])
dispense cfinger [coke|door [number]]
dispense standalone [coke|telnet|both]
dispense [server|telnet]
dispense passwd [user]
http://.../cgi-bin/dispense/html.(menu|auth.n|disp.n)
dispense is the UCCs interface to the coke machine and the door. This allows you to drop a coke (or another drink) can from the machine. You can also use credit from dispense to pay for other items such as phone calls.
If you do not specify a command line parameter the dispense program will bring up a menu based selection screen (the drinks-only option will omit "other" items from this menu). From this screen you can select the item to drop by pressing a number or moving up and down with the k (or ^P) and j (or ^N) keys, as well as VT100 (or similar) arrow keys, and then pressing one of enter, space or d to dispense the item. By pressing q or the escape key you can quit from this section without dropping a can. If you are in the coke.controllers file in the coke servers /var/coke there is also the function n which allows you to change the name of the current slot, the function p to change the price of the drinks in the current slot and the r (or f) function to reset accounting data for a slot.
On the command line you can specify a number or a name of the can to drop. If you specify a number it is taken as the slot number (this assumes you already know which slot it is in). If you specify a name it trys to find the can of the appropriate type and drop that. If it fails it will print appropriate error messages.
Using the -u option it is possible for coke controllers to run dispense for someone else. By using the -c option a given number of an item can be dispensed, or the menu can be automatically recalled a given number of times.
dispense Will run the dispense program in interactive mode. dispense 2 Will drop a can from slot 2. dispense drinks-only Will bring up a menu with only drinks on it. dispense club lemon Will drop a club lemon can out of the machine. So will dispense cl (usually) but dispense c will do interesting things (dispense the first drink beginning with c, unless there are no drinks in any slots beginning with c, in which case it will complain there is none of the last drink beginning with c).
dispense can also be used by "coke controllers" to configure the menus from the command line. The options in the second form of dispense (from above) are listed below.
"-h" show help "-R" reset all slots "-r "slot reset slot number slot "-s ""slot price "[name] set slot number slot to price price and optionally change the name to name
dispense -r 3 reset slot 3 dispense -s 3 78 set slot 3 to a cost of 78 units dispense -s 2 73 coke set slot 2 to a cost of 73 units and a name of coke
dispense door will open the door for users listed in the door.controllers file in the door servers /var/coke directory.
"dispense acct" [user [+|-|=] amount] "reason" will modify the account of user to add or subtract amount or set the balance to amount, respectively and log the reason as reason.
"dispense give ""user amount" will give amount cents from your coke account to user.
"dispense finger "(coke|door [number]) will give information about the status of the coke machine or the doors around the guild building. If you specify a number the program will display only that door and exit with an appropriate status. If the number is negative, then all doors except the specified one are queried.
"dispense cfinger "[coke|door [number]] will give similar information in a GNU-cfinger format. This is run from inetd if wanted. If no parameter is specified information about both the coke machine and the doors will be given.
dispense passwd [user] will change your UCC password, or the password of user if you give the old password.
dispense server will start a server process if called from the inetd. This is typically done by:
"ucc stream tcp nowait coke /usr/local/etc/dispense ucc server"
in /etc/inetd.conf, but this may be different if you use TCP wrappers. The syntax for this server is given in the NOTES below.
dispense telnet will start a telnet process to the coke machine, and should also be called from inetd. This is typically done by
"telnet stream tcp nowait root /usr/local/etc/dispense ucc telnet"
in /etc/inetd.conf (or similar for TCP wrappers).
"dispense standalone "[coke|telnet|both] is an alternative way of running the servers, which will attempt to bind to the specified ports (ucc ["coke"], telnet ["telnet"] or both ["both"]) and run the UCC Coke/Auth service and/or UCC Incoming Telnet service on these ports.
http://.../cgi-bin/dispense/html.(menu|auth.n|disp.n) is the syntax for the web interface to dispense. This is mostly used by accessing http://.../dispense/html.menu.
dispense acct luyer +20 "20c deposit receipt 12345" will add 20 cents to luyers coke account with the reason "20c deposit receipt 12345". "dispense finger door" will give status information about all the doors. "dispense cfinger" will give cfinger-format information about the coke machine and door. "lynx http://ucc.gu.uwa.edu.au/cgi-bin/dispense/html.menu" will bring up a menu of the coke machine contents at ucc.gu.uwa.edu.au.
Exit codes
"-4" is returned if an attempt is made to start the coke server from the command line (except via rsh or as a standalone daemon). "-3" is returned if an illegal function call was made in the coke library. "-2" is returned if the remote username or password was invalid. "-1" is returned if there was a problem connecting to the remote coke server. "0" is returned if the operation was successful. "1" is returned if the command line arguments (or html form contents) were invalid, or if the user attempted to do something they are not permitted, for example if they are not a coke controller and attempted to do a coke control command. "2" is returned if there was a miscellaneous error, such as permissions problems, problems identifying the user, errors interacting with the coke machine, or an unexpected signal was recieved. "3" is returned if the slot specified is empty. "4" is returned if the credit was insufficient. "5" is returned if no match for the name given was found. "6" is returned if the operation was aborted by the user. "dispense finger door "number returns 0 if the door is open, 1 if the door is closed or 2 if the door is malfunctioning.
David Luyer <luyer@ucc.gu.uwa.edu.au>
The dispense program is property of the UCC and the author. The author (David Luyer) maintains copyright over all source code. Permission is given to copy all binaries of the code to anywhere you may wish to run them at no cost.
/var/coke/* on the coke and door server(s)
Attempting to load the menu selection screen from a Linux machine being accessed from MacTelnet can, under certian shells, cause a segmentation fault in the program.
The remote version of dispense acct displays zero balances for users without valid accounts, but still adds their current balance into the Total credits.
As mentioned above, the distributed coke software uses a server (dispense server) running on port 375. This can also be used to interact with the UCC coke/door system. The syntax for this server is documented below:
Go to Top of page.
Command Args Before After Replies -- -- -- INIT 200-ucc server ready 200 services available: coke door -- INIT_P 200-ucc server ready (preauth) 200 services avaliable: coke door -- -- 574 network error -- -- 575 cant getpwnam coke -- -- 576 getpeername: %s user %s INIT* USER 300 send pass for %s INIT* INIT 500 invalid user %s preauth %s INIT_P USER 203 preauth ok INIT_P INIT 501 invalid or wrong user %s xuser -- USER INIT 310 send real user pass %s USER PASS 201 login ok USER INIT 502 login incorrect !USER static 520 pass not expected salt %s INIT* USER_C 301 send crypt for %s, salt %s INIT* INIT 500 invalid user %s opass %s USER PASS_O 302 send new crypt for %s USER INIT 502 login incorrect USER INIT 504 opass rejected for root !USER static 521 opass not expected crypt %s USER_C PASS 280 login ok, authority ok USER_C INIT 590 login ok, authority bad USER_C INIT 502 login incorrect PASS_O PASS 281 password changed ok PASS_O INIT 503 error changing password nopass -- USER* PASS 202 nopass ok USER* static 510 unable to confirm access for nopass USER* static 511 unauthorised network for nopass USER* static 512 unauthorised host for nopass USER* static 513 unauthorised port for nopass balance [%s] PASS PASS 210 balance [for %s] %ld PASS PASS 500 invalid user %s PASS PASS 520 cokebank open error first -- PASS PASS 216 balance including %s %ld PASS PASS 520 cokebank open error PASS PASS 523 end of cokebank next -- PASS PASS 216 balance to %s %ld PASS PASS 522 cokebank not open error PASS PASS 523 end of cokebank close -- PASS PASS 290 cokebank closed bytebal [%s] PASS PASS 210 balance [for %s] %ld bytes PASS PASS 500 invalid user %s PASS PASS 520 cokebank open error control -- PASS PASS 260 control true PASS PASS 551 control false dctl -- PASS PASS 261 door control true PASS PASS 552 door control false dopen -- PASS PASS 270 door opened PASS PASS 422 door open failed PASS PASS 550 permission denied become -- PASS PASS 204 user changed ok PASS PASS 500 invalid user %s PASS PASS 550 permission denied status -- PASS PASS 220-status begin [...] 220 status end PASS PASS 400 error getting status reset all PASS PASS 212 slots reset ok PASS PASS 401 error resetting slots PASS PASS 550 permission denied reset %d PASS PASS 213 slot reset ok PASS PASS 402 error resetting slot PASS PASS 550 permission denied acct * PASS PASS 211 new balance for %s %ld PASS PASS 500 invalid user %s PASS PASS 520 cokebank open error PASS PASS 540 parse error PASS PASS 550 permission denied bytes * PASS PASS 211 new balance for %s %ld bytes PASS PASS 500 invalid user %s PASS PASS 520 cokebank open error PASS PASS 540 parse error PASS PASS 550 permission denied set * PASS PASS 214 name set ok PASS PASS 215 price set ok PASS PASS 400 error getting status PASS PASS 403 error setting name PASS PASS 404 error setting price PASS PASS 530 invalid price PASS PASS 540 parse error PASS PASS 550 permission denied dial %s PASS PASS 100 warning: credit negative PASS PASS 232-dialed ok 232 credit left: %ld PASS PASS 233 freecall dialed ok PASS PASS 430-error dialing 430 credit unchanged PASS PASS 431 freecall failed PASS PASS 520 cokebank open error PASS PASS 561 not enough credit PASS PASS 531 invalid phone number disp %d PASS PASS 100 warning: credit negative PASS PASS 230-dispense ok 230 credit left: %ld PASS PASS 231 dispense attempt done PASS PASS 400 error getting status PASS PASS 410 dispense attempt failed PASS PASS 411-dispense failed 411 credit unchanged PASS PASS 520 cokebank open error PASS PASS 560 slot empty PASS PASS 561 not enough credit give %d %s PASS PASS 100 warning: credit negative PASS PASS 211-new balance for %s %ld 211 new balance for %s %ld PASS PASS 500 invalid user %s PASS PASS 520 cokebank open error PASS PASS 561 not enough credit PASS PASS 562 cannot give negative credit door %d -- * static 222 door %d status %d * static 420 door not specified * static 421 illegal door finger -- * static 221-finger begin [...] 221 finger end * static 400 error getting status slots -- * static 223 have %d slots %d pseudoslots help -- * static 580 not implemented noop -- * static 250 nothing done quit -- * -- 240 session completed bad command 570 error: %s null command 571 no input serious error 572 fatal internal error timeout 573 read error or timeout
Syntax for "*" commands above: (acct|bytes) (add|sub|set) %d %s %[^0 set (name %d %s)|(price %d %d)
| DISPENSE (1) | "5 March 1996" |