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.

Note: Scripts cannot be run in Windows 95, NetWare, and FreeBSD guest operating systems.

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 deselect 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

One or more default scripts for each power state are included in VMware Tools. These scripts are located in /etc/vmware-tools on UNIX guests, or C:\Program Files\VMware on Windows guests.

Script Name

Description

suspend-vm-default

If you configured the suspend operation to suspend the guest, this script runs when the virtual machine is being suspended.

On Windows guests, if the virtual machine is configured to use DHCP, this script releases the IP address of the virtual machine.

On Linux, FreeBSD, and Solaris guests, this script stops networking for the virtual machine.

resume-vm-default

If you configured the power-on operation to start the guest, or the reset operation to restart the guest, this script runs when the virtual machine is resumed after it was suspended.

On Windows guests, if the virtual machine is configured to use DHCP, this script renews the IP address of the virtual machine.

On Linux, FreeBSD, and Solaris guests, this script starts networking for the virtual machine.

poweroff-vm-default

If you configured the power-off operation to shut down the guest, this script runs when the virtual machine is being powered off.

If you configured the reset operation to restart the guest, this script runs when the virtual machine is being reset.

This script has no effect on networking for the virtual machine.

poweron-vm-default

If you configured the power-on operation to start the guest, this script runs when the virtual machine is being powered on rather than resumed.

If you configured the reset operation to restart the guest, this script runs after virtual machine restarts.

This script has no effect on networking for the virtual machine.

Using Your Own Scripts

You can use the default script or you can substitute a script you create 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, deselect the Use Script check box.

 
3.
Click Apply to save your settings.

 


VMware Tools Help