i'm having difficult to write a script to access by using the x3270 emulator.
the machine is linux redhat.
I'd love to use php, do you have some example?
i have tried this, it opens the windows of x3270 but it seems stuck, i don't get how can i print in a txt file what i see on the screen.
<?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
}
thank you.