[Contents] [Index] [Help] [Retrace] [browse <] [Browse >]


NAME
    Execute -- Execute a CLI command

SYNOPSIS
    success = Execute( commandString, input, output )
    D0                 D1             D2     D3

    BOOL Execute(STRPTR, BPTR, BPTR)

FUNCTION
    This function attempts to execute the string commandString as a
    Shell command and arguments. The string can contain any valid input
    that you could type directly in a Shell, including input and output
    redirection using < and >.  Note that Execute() doesn't return until
    the command(s) in commandstring have returned.

    The input file handle will normally be zero, and in this case
    Execute() will perform whatever was requested in the commandString
    and then return. If the input file handle is nonzero then after the
    (possibly empty) commandString is performed subsequent input is read
    from the specified input file handle until end of that file is
    reached.

    In most cases the output file handle must be provided, and is used
    by the Shell commands as their output stream unless output
    redirection was specified. If the output file handle is set to zero
    then the current window, normally specified as *, is used. Note
    that programs running under the Workbench do not normally have a
    current window.

    Execute() may also be used to create a new interactive Shell process
    just like those created with the NewShell command. In order to do
    this you would call Execute() with an empty commandString, and pass
    a file handle relating to a new window as the input file handle.
    The output file handle would be set to zero. The Shell will read
    commands from the new window, and will use the same window for
    output. This new Shell window can only be terminated by using the
    EndCLI command.

    Under V37, if an input filehandle is passed, and it's either
    interactive or a NIL: filehandle, the pr_ConsoleTask of the new
    process will be set to that filehandle's process (the same applies
    to systemtaglist()).

    For this command to work the program Run must be present in C: in
    versions before V36 (except that in 1.3.2 and any later 1.3 versions,
    the system first checks the resident list for Run).

INPUTS
    commandString - pointer to a null-terminated string
    input         - BCPL pointer to a file handle
    output        - BCPL pointer to a file handle

RESULTS
    success - BOOLEAN indicating whether Execute was successful
              in finding and starting the specified program.  Note this
              is NOT the return code of the command(s).
SEE ALSO
    systemtaglist(), newshell, endcli, run