Node:Making Alterations, Next:, Previous:File Transfer Modes, Up:Top



Making Alterations

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
ACCT specifies the name of the account that is being published.
-w DIR
DIR specifies the local base directory of the website that is being published.
-s FTP
FTP specifies the name of the server that the file is being transferred too.
-u USER
USER specifies the user name that was used to log into the FTP server.
-e EXT
EXT specifies the extension of the file that is being transferred.
-d DIR
If this argument is included on the command line then DIR specifies the offset directory on the server for the account that is being published.

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.