Previous Topic: run-winRemote Command--Execute a Command on Multiple Remote Windows Systems (Funclet)Next Topic: set console Command--Suppress Console Output (Cmdlet)


set alternate to Command--Set Alternate Output File (Cmdlet)

This command (cmdlet) sets or resets an alternate output file, for example, for ?, ??, qout(), or qqout(). When setting an alternate output file, any output from commands or functions is not only written to stdout, but also to the specified file. To write to only the alternate output file, suppress stdout using the "set console off" command.

The command has the following syntax:

set alternate to outFile [-append]
outFile

Specifies a string with an absolute or relative path of the alternate output file. If no file name is specified, the command restores the alternate output stream to the previous setting.

-append

(Optional) Appends the output stream to the specified file.

Examples

Write numbers 1 through 10 to output.txt and the console:

set alternate to output.txt
for(i=1; i<11; i++)
{
    ? i
}
set alternate to

Append numbers 11 through 20 to output.txt and the console:

set alternate to output.txt -append
for(i=11; i<21; i++)
{
    ? i
}
set alternate to

Write a directory listing to a file:

set alternate to dir.txt
dir -l
set alternate to