UNIX および Windows で有効です。
注: この関数は、CA Client Automation で新しく使用されるようになったため、古いバージョンのスクリプト インタープリタでは動作しません。
OpenPipe 関数は、クライアント役割の読み書き用の名前付きパイプを開きます。
関数の形式
OpenPipe(pipename as String, access as Integer) as Integer
オープンするパイプの名前を指定します。
UNIX では、pipename は有効なパス名です。
Windows では、\\.\pipe\xxx の形式になります。ここで、xxx には「\」を除く任意の文字列を含むことができます。
パイプを使用する方向を指定します。
(値 0)読み取りのために開きます。
(値 1)書き込みのために開きます。
返されたファイル ハンドルは、関数 ReadFile、WriteFile、および CloseFile で使用できます。 OpenPipe はパイプ クライアントとして機能するプロセス内で使用します。 OpenPipe を呼び出す前に、CreatePipe を呼び出します。
パイプは、ブロック モードで機能します。 OpenPipe の後に続く読み書き関数は、サーバが反対の関数を使用するまで待機します。
この関数が正常に完了すると、負でない整数(ファイル ハンドル)が返されます。 この関数が失敗すると、-1 が返されます。
例:
以下の例では、名前付きパイプ クライアントを表示します。
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 © 2014 CA Technologies.
All rights reserved.
|
|