base.Channel.openPipe()

Before a channel object can be used, a channel associated with it must be opened. It can be either a file, a socket or a pipe. If a channel is not opened, any other methods associated with it will have no effect and will return a runtime error.

openPipe() provides you with the ability to write to the standard output, to read from an sub-process standard output, or to perform both these operations. The method requires 2 arguments.

Syntax:

chan_obj.openPipe(command CHAR, flag CHAR)

Mode

Flag

Effect

Read Only mode

r

Perform a reading operation from the command standard output.

Write Only mode

w

Perform a writing operation to the command standard input.

Append mode

a

Perform a writing operation to the command standard input by appending the existing content.

Read and write mode

u

Perform both reading and writing operations with the command standard input.

Usage example:

MAIN
 DEFINE osType,host_name STRING
 DEFINE chan_obj base.Channel
    LET chan_obj = base.Channel.Create()
    CALL ui.Interface.frontCall("standard", "feinfo", "ostype", osType)  --get operating system
    LET osType = osType.toUpperCase()
    IF osType = "WINDOWS" THEN
	 CALL chan_obj.openPipe("hostname", "r")
    ELSE 	#running on Unix/Linux
	 CALL chan_obj.openPipe("uname -n", "r")
    END IF
    CALL chan_obj.READ(host_name)
    DISPLAY host_name
END MAIN

 

Contact Us

Privacy Policy

Copyright © 2025 Querix, (UK) Ltd.