%Cookies for Message File Replies

NcFTPd supports a few special character sequences, called "percent cookies" or "%cookies", which refer to the syntax of the sequences.  When the server outputs a message file back to the client, such as the welcome message, NcFTPd replaces these sequences with something meaningful.

These %cookies are only evaluated during the following instances:

For example, you might create a cookie-laden login message like this:

***************************
*                         *
* You are now logged in.  *
*                         *
***************************
Here is a percent, %% embedded.
Time is now %T in Omaha, or %tY-%tm-%td %tH:%tM:%tS.
Your user name is %U.
Your email address is %E.
You are user number %N of %M total.
You have connected to me, %L (%D)
from %R (%I).
***************************

Which, upon logging in, might look like this to the user:

230-You are user #1 of 20 simultaneous users allowed.
230-
230-***************************
230-*                         *
230-* You are now logged in.  *
230-*                         *
230-***************************
230-Here is a percent, % embedded.
230-Time is now Sun Feb 20 08:51:21 2000 in Omaha, or 2000-02-20 08:51:21.
230-Your user name is anonymous.
230-Your email address is mgleason@example.com.
230-You are user number 1 of 20 total.
230-You have connected to me, www.ncftp.com (www-set)
230-from cse.unl.edu (129.93.33.1).
230-***************************
230-
230 Logged in anonymously.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> 

For example, notice how the "%T" in the login message file was dynamically translated to "Sun Feb 20 08:51:21 2000" when the user logged in.

Here is the list of %cookies available for reply files and what they expand to.  Note that some %cookies aren't applicable until the user is logged in; in those cases, the cookie expands to "?".

%T
The current time, as it would be printed in the standard format used by the date command.
 
%tx
The current time, using a sub-cookie %x as used by date.  For example, if you don't like the whole date as printed by the NcFTPd cookie %T, you could use date (and the system library function strftime()) cookies to display the time in your preferred format.  So if you wanted to print just the current time as HH:MM:SS, such as "date +%H:%M:%S" for date , you could do this using NcFTPd by using  %tH:%tM:%tS.
 
%U
The username of the currently logged in user.
 
%M
The maximum number of users that can login to the server (or domain, if you have limited individual domains using max-domain-users).
 
%N
The current number of users logged into the server (or domain, if you have limited individual domains using max-domain-users).
 
%E
The e-mail address, or more accurately, whatever the user entered in for their password when logging in anonymously.  This may be truncated if the user entered in a really long e-mail address.
 
%D
The current domain the user is logged into, or more accurately, the set-name for the domain in use.
 
%L
The server-name of the domain the user is logged into, or if not set, the hostname that was resolved from server-address, or if that didn't resolve, the IP address from server-address.  Think of this as the local host name.
 
%R
The remote host name the user is connecting from, or their IP address if the host name was not available.
 
%I
The IP address the user is connecting from.
 
%qbh
If the user has a NcFTPd disk quota set using ncftpd_edquota, this expands to the bytes hard limit, otherwise if no quota is set it expands to "(not applicable)".
 
%qbu
Expands to the number of bytes used, or "(not applicable)" if the user doesn't have a quota.
 
%qfh
The hard-limit for number of files, or "(not applicable)" if the user doesn't have a quota.
 
%qbu
The number of files used, or "(not applicable)" if the user doesn't have a quota.
 
%qt
The number of seconds of wall-clock time spent calculating the quota.
 
%bup
If the user has a bandwidth limit set, this expands to the number of kilobytes the user is limited to for uploads, otherwise it expands to "(not applicable)".
 
%bdn
If the user has a bandwidth limit set, this expands to the number of kilobytes the user is limited to for downloads, otherwise it expands to "(not applicable)".
 
%sbd
The number of bytes downloaded.
 
%sbu
The number of bytes uploaded.
 
%sbt
The number of bytes transferred (downloaded + uploaded).
 
%sfd
The number of files downloaded.
 
%sfu
The number of files uploaded.
 
%sft
The number of files transferred (downloaded + uploaded).
 
%sts
The number of seconds the user has been connected.
 
%stf
The amount of time the user has been connected, formatted as HH:MM:SS.
Up
NcFTPd HomeNext: Example 1