A sequential number dispenser

© 2004 Antone Roundy
Latest Documentation



A CGI script could do what SerialND does without too much trouble, so why use SerialND? Here are a few possible reasons:


The following are required to use SerialND:


  1. If desired (and if you have access to do so), create a new user account for SerialND to execute as. You may also run it using an existing account--it makes little difference.
  2. Udpate "serialndusergrp" near the top of with the username and group name (in the form "username:groupname") you want SerialND to execute as.
  3. Update the paths in the configuration section of to point to suitable locations for storing a cache file (to keep track of the last serial number issued) and the named pipe from which clients will read the serial number. The directory must be modifieable by SerialND and should not be modifiable by others (should not be world writable, and perhaps not group writable).
  4. Create the cache file a the location you specified. It may be empty, or may have the number you'd like SerialND to start at in it.
  5. Ensure that the access permissions for the cache file are set so that SerialND will be able to modify it.
  6. Upload to a suitable location such as /usr/bin, /usr/sbin, or some location in your user directory.
  7. Make sure that is executable by setting the "execute" bit in its permissions.
  8. The following steps assume you are running on a UNIX-like system. SerialND may work, but is not supported, on other types of systems:
    Update the path in to point to the location where is located.
  9. Upload to /etc/init.d/ or whatever the location is where scripts are stored on your system to launch daemons.
  10. Make executable.
  11. Create symlinks to in your /etc/rd#.d/ directories, or whatever is necessary to launch SerialND on your system.


To get a number from SerialND, have your script open the file pointed to by $frontdoor in, read one line from it, and close it. The line that was read will be a number followed by a newline character, so you may have to do something (like adding zero to it, running it through a trim or chop function, etc.) to ensure that it's treated as a number. Here's some PHP code to do that:

If ($f=fopen('/path/to/frontdoor/file','r')) {
} // else an error occurred