24 lines
524 B
Plaintext
24 lines
524 B
Plaintext
#
|
|
# piped.icn, Get system command output
|
|
#
|
|
# Dedicated to the public domain
|
|
#
|
|
procedure main()
|
|
# start with an empty list
|
|
directory := []
|
|
|
|
# ls for UNIX, dir for other, assume Windows
|
|
command := if &features == "UNIX" then "ls" else "dir"
|
|
|
|
# open command in pipe mode
|
|
p := open(command, "p") | stop("Cannot open pipe for ", command)
|
|
|
|
# read in results and append to list
|
|
while put(directory, read(p))
|
|
|
|
# display the fifth entry, if there is one
|
|
write(\directory[5])
|
|
|
|
close(p)
|
|
end
|