Writing a Program File (Executable)

Author: Carl Sassenrath
Return to REBOL Cookbook

On some systems, such as Linux, BSD, HPUX, Solaris, etc., when you download an executable program file, you need to set the file permissions to allow the file to be executable. To do that, use the SET-MODES function:

    set-modes file permissions-block

For example, to download and save an executable copy of REBOL/Core for Linxu:

    url: ftp://anonymous@www.rebol.com/pub/downloads/core/rebol042
    data: read/binary url
    write/binary %rebol042 data
    set-modes %rebol042 [owner-execute: true]

The file rebol042 can now be executed.

Note that SET-MODES is not required for Windows programs, so to prevent an error on Windows you can either remove the SET-MODES or trap and ignore the error with a line such as:

    attempt [set-modes %rebol042 [owner-execute: true]]

If you want to execute the program from REBOL, you need REBOL/Pro features (such as those in REBOL/Command or /SDK). The line would be:

    call "rebol042"

2006 REBOL Technologies REBOL.com REBOL.net