Node:Making Alterations, Next:Publishing a Website, Previous:File Transfer Modes, Up:Top
WebPublish is generally used to publish a local copy of a website to one or more remote servers. Often, it is necessary to make changes to a file when it is transferred to a remote server. An HTML file, for example, may need to have a time stamp added. Also, files that use a <BASE> tag should have the base directory changed to work correctly from the server. WebPublish includes a feature that allows a shell program to be called just before a file with an associated file extension is about to be transferred. This makes it easy to write a script or a program that can alter a file just before it is transferred.
The shell
database file contains a list of file extensions.
Each file extension that is listed in the shell
database file
has a shell program associated with it. Just before WebPublish
transfers a file to a remote server, WebPublish will search the
shell
database file. If the extension for the file that is
being transferred matches a record in the shell
database file
then WebPublish will call the shell program that is associated with
the file extension. The shell program can then change the file that
is about to be transferred.
Each association is specific to each WebPublish account. That is,
if you associate a shell program with the html
file extension
using the weedguy
account then the shell program will only be
called when you publish the weedguy
account. If you want a shell
program to be called with other accounts then you will have to
associate the shell program with an extension for each account.
Each time that WebPublish executes a shell program, WebPublish will include the account information on the shell program command line. The account information that is passed to the shell program as command line arguments are:
-a ACCT
-w DIR
-s FTP
-u USER
-e EXT
-d DIR
The shell program can read in the file from stdin and write the file to stdout. If the shell program does not make any changes to the file then the shell program can return 2. If the shell program returns a value of 2 then WebPublish will transfer the original file. If the shell program makes changes to the file then the shell program can return 3. If the shell program returns a value of 3 then WebPublish will transfer the file that was written to stdout by the shell program. If the shell program encounters an error then the shell program can return 1. If the shell program returns a value of 1 then WebPublish will report an error and terminate.
NOTE: stdout is piped to a temporary file in the WebPublish
working directory ($HOME/.webpublish
). Therefore, the local copy
of the website file is never altered by the alteration function.