1

x3270 エミュレーターを使用してアクセスするためのスクリプトを作成するのに苦労しています。

マシンは linux redhat です。

私はphpを使いたいのですが、例はありますか?

x3270のウィンドウを開きますが、スタックしているようです。画面に表示されているものをtxtファイルに印刷する方法がわかりません。

<?php $descriptorspec = array(
        0 => array("pipe","r"),
        1 => array("pipe","w"),
        2 => array("pipe","w")
       );

process = proc_open('/usr/local/bin/x3270', $descriptorspec, $pipes, null, null);
stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0); 

function expecttxt ($thetxt) {
      global $pipes;
      $x = false;
      $g = false;
      while ($x == false) {
            sleep(1);
         while ($mydat = fgets($pipes[1])) {
                        if (preg_match("/$thetxt/i", $mydat)) {
                        $g = true;
                  }
                  if ($g == true) {
                        while ($mydat = fgets($pipes[1])) {
                        }
                        $x = true;
                        break 2;
                  }
         }
      fwrite($pipes[0], "ascii()\n");
      }
} 

if(is_resource($process)) {
      fwrite($pipes[0], "connect(L:hostname:port)\n");
      fwrite($pipes[0], "ascii()\n");
      expecttxt("CDN");
      fwrite($pipes[0], "string(session-name)\n");
      fwrite($pipes[0], "enter\n");
      fwrite($pipes[0], "ascii()\n");
      expecttxt("SESSION STATUS");
      fwrite($pipes[0], "PF(2)\n");
      fwrite($pipes[0], "ascii()\n");
      expecttxt("NEXT INFO");

      //...etc

} 

ありがとうございました。

4

0 に答える 0