System Feature
stream
Purpose
Directs the flow of data among commands, files, screen, variables, etc.
Syntax
No explicit syntax.
Description
A stream is flow of data. Every command has three streams associated with it.
Input Stream
Command takes its input from this stream. Some commands, such as scd (Show Current
Directory), ignore data in input stream.
Output Stream
Command writes its output to this stream. Commands that don't have any output, ignore
this stream.
Error Stream
Command writes any errors it encounters to this stream.
All streams can be redirected to valid stream destinations, which are listed below.
Valid Stream Destinations
Valid stream destinations are as follows. (They are also called redirection targets.)
screen This is the default destination unless the stream is redirected.
file
Stream data is redirected to/from a file. Files can be local, on a local network,
or on internet.
variable
Stream data is redirected to/from a variable. The type of variable must be str (string).
NULL For input, data is ignored. For output and error, data is suppressed (and not
written anywhere).
pipe (|)
Output from one command is input to the next command.
inline command
An inline command whose output is a valid destination.
For details on how to specify pipe as a stream destination, see help page on pipe.
For details on how to specify other stream destinations, see the help pages on input, output,
and error.
If a stream is redirected to/from a file, IT IS RECOMMENDED THAT ABSOLUTE PATH NAME FOR THE FILE
BE SPECIFIED. Consider the following example.
cd "C:/"
# List all directories
var str dirList
lf -n "*" "." ($ftype=="d") > $dirList
# Go into each directory, and list files there.
var str dir
while ($dirList <> "")
do
lex "1" $dirList > $dir
cd $dir
lf -n "*" "." ($ftype=="f") >> fileList.txt ### <==== Watch this redirection.
done
The lf command will list files in each directory, and will write its output to fileList.txt in that
directory. This will create a fileList.txt file in each directory. If that's what you want, then this
would work. But, if you want to write the output of all lf commands to just one output file,
use the following redirection in terms of absolute path name.
lf -n "*" "." ($ftype=="f") >> "C:/fileList.txt"
Similarly, we recommend enclosing absolute path names in double quotes.
Restrictions
All the access permissions apply to streams. For example, if you do not have permission to write
to a local file, specifying that file as the output stream destination will produce error.
Similarly, if a file is at a web site (has the prefix of http://), and if you do not
have permission to access that file, an error will be produced.
Stream redirection is preferred over inline commands for variable assignment. For example,
for a str variable s, instead of
set $s={ lex "1" $text }
the following is preferred.
lex "1" $text > $s
Valid Examples
The following are examples of valid stream destinations.
"C:/My Directory/My File"
"http://www.mywebsite.com/index.html"
Invalid Examples
The following are examples of invalid stream destinations.
C:/My Directory/My File
Will produce an error since the file name has spaces and it is not enclosed within double quotes.
"C:/My Directory/"
Will produce an error since "My Directory" is a directory (assuming) and not a file.
See Also
pipe
input
output
error
mf
|
© 2008-2012, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com.
Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.
|