Mac Classic

Writing a script

Sometimes it’s more useful to put a number of commands into an Open Firmware script rather than entering them directly into the Forth ‘shell’.

Scripts can be written with any text editor that can create .txt files. This is the default file type for the application SimpleText, which is included in most early Mac OS systems.

Below is a script that changes the CPU version and fan speeds for an Apple PowerBook G4. The first line of the script must contain an Open Firmware\ comment, followed by a cr (carriage return).

\ comment
cr

dev /cpus/PowerPC,G4@0
80010201 encode-int " cpu-version" property
device-end

" fan" open-dev constant fan-ih
1 340 " set-speeds" fan-ih $call-method

boot hd:,\\:tbxi
The final line of this script instructs the machine to boot from the default hard drive after running the desired commands.

Running a script

Make sure your script is saved to a convenient location such as the root of your HD. In this example the file has been named ‘bootscript’, and is located at the root of the HD.

To run the script at boot you will need to boot into Open Firmware (by holding the ‘Command’ + ‘Option’ + ‘O’ + ‘F’ keys) and running the following command:

setenv boot-device hd:\bootscript

This sets the boot-device variable to the 'bootscript' rather than the default HD (\\:tbxi).

Finally, run the reset-all command to restart the machine.

Post a Comment