Previous: Status Mode, Up: Genfile


E.3 Exec Mode

This mode is designed for testing the behavior of paxutils commands when some of the files change during archiving. It is an experimental mode.

The ‘Exec Mode’ is toggled by --run command line option (or its alias -r). The non-optional arguments to getopt give the command line to be executed. Normally, it should contain at least the --checkpoint option.

A set of options is provided for defining checkpoint values and actions to be executed upon reaching them. Checkpoint values are introduced with the --checkpoint command line option. Argument to this option is the number of checkpoint in decimal.

Any number of actions may be specified after a checkpoint. Available actions are

--cut file
--truncate file
Truncate file to the size specified by previous --length option (or 0, if it is not given).
--append file
Append data to file. The size of data and its pattern are given by previous --length and pattern options.
--touch file
Update the access and modification times of file. These timestamps are changed to the current time, unless --date option was given, in which case they are changed to the specified time. Argument to --date option is a date specification in an almost arbitrary format (see Date input formats).
--exec command
Execute given shell command.
--unlink file
Unlink the file.

Option --verbose instructs genfile to print on standard output notifications about checkpoints being executed and to verbosely describe exit status of the command.

While the command is being executed its standard output remains connected to descriptor 1. All messages it prints to file descriptor 2, except checkpoint notifications, are forwarded to standard error.

Genfile exits with the exit status of the executed command.

For compatibility with previous genfile versions, the --run option takes an optional argument. If used this way, its argument supplies the command line to be executed. There should be no non-optional arguments in the genfile command line.

The actual command line is constructed by inserting the --checkpoint option between the command name and its first argument (if any). Due to this, the argument to --run may not use traditional tar option syntax, i.e., the following is wrong:

     # Wrong!
     genfile --run='tar cf foo bar'

Use the following syntax instead:

     genfile --run='tar -cf foo bar' actions...

The above command line is equivalent to

     genfile actions... -- tar -cf foo bar

Notice, that the use of compatibility mode is deprecated.