Valid on UNIX and Windows
Note: This function is new in CA ITCM and does not work with older versions of the Script Interpreter.
The OpenPipe function opens a named pipe for reading or writing a client role.
This file content function has the format:
OpenPipe(pipename as String, access as Integer) as Integer
Specifies the name of the pipe to be opened.
On UNIX pipename is a valid pathname.
On Windows it has the form \\.\pipe\xxx where xxx can contain any characters except '\'
Specifies in what direction the pipe is used.
(value 0) Opened for reading.
(value 1) Opened for writing.
You can use the returned file handle with the functions ReadFile, WriteFile, and CloseFile. OpenPipe is used in the process that acts as a pipe client. Before you call OpenPipe, you must call CreatePipe.
The pipe works in blocking mode. The read or write functions following OpenPipe wait until the server uses the inverse function.
On successful completion the function returns a non-negative integer, which is the file handle. If the function fails, it returns -1.
Example: OpenPipe function
This example shows a named pipe client. The example reads a command from the pipe given as first argument and writes the response to pipe given as second argument.
dim rc, h0, h1, i as integer
dim pnam0, pnam1 as string
dim stopstring as string
dim s, s1 as string
dim iswin as boolean
pnam0 = argv(1)
pnam1 = argv(2)
stopstring = "---END---"
h0 = OpenPipe(pnam0, O_READ)
h1 = OpenPipe(pnam1, O_WRITE)
if h0 < 0 or h1 < 0 then
print "open pipe failure. h0: " + str(h0) + " h1: " + str(h1)
print "pnam0: " + pnam0 + " pnam1: " + pnam1
exit
end if
rc = ReadFile(h0, s)
print "read command rc: " + str(rc) + " " + s
if rc then
for i = 1 to 5
s1 = "RSP " + s + " line " + str(i)
rc = WriteFile(h1, s1)
if not(rc) then
print "write failed: " + s1
exit for
end if
next i
if rc then
rc = WriteFile(h1, stopstring)
if rc then
print "test successful"
end if
end if
end if
CloseFile(h0)
CloseFile(h1)
|
Copyright © 2013 CA.
All rights reserved.
|
|