Defining precommands and postcommands
The Pre/Post Commands dialog box lets you execute commands on a target directory before and after a package is deployed to a server. It also lets you execute commands on a target directory before a deployment is undone and after it is undone.
A precommand or postcommand can consist of a number of commands that can be executed by the native operating system of a remote host. After you define precommands or postcommands, they are saved to the file server as script files. When a job runs, it uses the nexec -e command to execute the precommand or postcommand. When you execute a precommand, the target directory is first created (if it does not already exist) and then the precommand is executed in the target directory. Postcommands are executed in the target directory.
You can create precommands and postcommands by entering commands in the text box or importing text from a file on any managed server.
To define pre/post commands
- Click Pre/Post Commands. The Pre/Post Commands dialog box opens.
- To define precommands and postcommands, click one of the following:
- Deploy tab — Define precommands and postcommands for a package deployment.
- Undo tab — Define precommands and postcommands for undoing a package deployment.
- For Deployment path, enter the path where precommands and postcommands, in script form, are written during deployment so they can be run on an agent.
By default, commands are written to /tmp.
The path can include a parameter. Enter the parameter manually or click Select Property
, which appears when you click in the Value column. (For more information about using this tool, see Inserting-a-parameter.) - Take any of the following actions:
- For Pre-command, enter the command that you want to execute before the deployment begins. To import the text of the command, click Browse
and navigate to the file containing that text.
If a precommand must execute successfully for the deployment to complete, select the Must have 0 exit status check box. For Post-command, enter the command that you want to execute after the deployment ends. Postcommands are executed in the target directory. To import the text of the command, click Browse and navigate to the file containing that text.
If a postcommand must execute successfully for the deployment to complete, select the Post command should have 0 exit status check box.
If necessary, click Zoom
to open a dialog box that gives you a larger text box to edit pre- and postcommands. When you finish editing the command, click OK.
- For Pre-command, enter the command that you want to execute before the deployment begins. To import the text of the command, click Browse
- Click OK to close the Pre/Post Commands dialog box.