VMware Tools Help
Table of Contents Previous Next Index


Using Scripts

Using Scripts

VMware Tools scripts can help automate guest operating system operations when you change the virtual machine’s power state. If VMware Tools is installed in the guest operating system, and if you configure a virtual machine’s power controls to use the “guest” options, one or more default scripts run on the guest whenever you change the power state of the virtual machine.

For example, when you power off the virtual machine, the poweroff-vm-default script runs in the following situations:

In VMware Fusion, this script runs if you use the default power-off option, which is called Shut Down Guest.

In other VMware products, this script runs if you set the virtual machine to shut down the guest rather than abruptly power off.

On the Scripts tab you can enable, disable, and run scripts that are associated with changing a virtual machine’s power state.

On a Windows host, provided the virtual machine is configured to use DHCP, the script that executes when you suspend a virtual machine releases the IP address of the virtual machine. The script that executes when you resume a virtual machine renews the IP address of the virtual machine.

On a Linux host, the script that executes when you suspend a virtual machine stops networking for the virtual machine. The script that executes when you resume a virtual machine starts networking for the virtual machine.

To run one of these scripts at some time other than during a power state change, select the script you want from the Script Event list, select Use Script, and click Run Now.

To disable a script, select the action associated with the script from the Script Event list and clear the Use Script check box.

Note: Default scripts for suspending and resuming are written to work together. If you disable the script of one of these actions, disable the script for the other action as well.

Using Default Scripts

A default script for each power operation is included in VMware Tools. These scripts are located in the guest operating system in /etc/vmware-tools.

When You …

This Default Script Runs

Suspend the guest operating system

suspend-vm-default

Resume the guest operating system

resume-vm-default

Power off or shut down the guest operating system

poweroff-vm-default

Power on the guest operating system

poweron-vm-default

Reset the guest operating system

poweroff-vm-default

poweron-vm-default

resume-vm-default (If restarting after a suspend operation)

Using Your Own Scripts

You can use the default script or you can substitute a script you created for each power state change. In addition, if you are logged in as root, you can test a script or disable the running of a script.

To use a custom script

 
1.
In the Script Event list, select the power operation with which to associate the script.

 
2.
Do one of the following:

 
To select a different script, click Custom Script, click Browse, and select the new script.

 
To edit a script, click Edit. The script opens in your default editor. Make your changes there.

Note: To edit scripts from the Scripts tab, xterm and vi must be installed in the guest operating system. The user trying to edit the script must be a root user and must have vi and xterm in his or her PATH. Otherwise, scripts can be edited manually in any text editor.

 
To test the script, click Run Now.

Note: If you plan to test scripts in a Turbolinux 7.0 guest operating system, you need to update the Turbolinux guest operating system. This is a known issue with Turbolinux. Go to ftp://ftp.turbolinux.com/pub/TurboLinux/stable/tested/Workstation/7/i586/initscripts-7.0.0-18.i586.rpm.

 
To disable the running of a script, clear the Use Script check box.

 
3.
Click Apply to save your settings.

 


VMware Tools Help