[Info-vax] simple image processing (long)
Henry Crun
mike at rechtman.com
Tue Aug 16 21:52:53 EDT 2011
On 16/08/11 20:18, Jan-Erik Soderholm wrote:
> Henry Crun wrote 2011-08-16 18:14:
>> On 16/08/11 11:44, Jan-Erik Soderholm wrote:
>>> Arne Vajhøj wrote 2011-08-16 00:25:
>>>> On 8/14/2011 5:46 AM, Jan-Erik Soderholm wrote:
>>>>> VAXman- @SendSpamHere.ORG wrote 2011-08-14 01:53:
>>>>>> In article<j26umk$3ub$2 at online.de>, helbig at astro.multiCLOTHESvax.de
>>>>>> (Phillip Helbig---undress to reply) writes:
>>>>>>> In article<00AB3D70.195A8D10 at SendSpamHere.ORG>, VAXman-
>>>>>>> @SendSpamHere.ORG writes:
>>>>>>>
>>>>>>>> Mark Berryman ported it and it works well. Simple to install. Execute
>>>>>>>> the PHP_SETUP and off you go.
>>>>>>>
>>>>>>> Today, I tried out his Ghostscript. Quite easy!
>>>>>>>
>>>>>>> I'm not using PHP with a web server (nor do I plan to anytime soon).
>>>>>>> Can PHP be used in a "standalone mode" to do what I want? (For now, I'm
>>>>>>> thinking mainly of things NOT served via HTTP but rather viewed in a
>>>>>>> browser with file:///.)
>>>>>>
>>>>>>
>>>>>> $ PHP -a ... for interactive mode...
>>>>>> $ PHP -a -f<filename> ... will process a PHP source...
>>>>>>
>>>>>> $ PHP -a
>>>>>> Interactive mode enabled
>>>>>>
>>>>>> <?php echo "Hello world!" ?>
>>>>>> ^Z
>>>>>> Hello world!
>>>>>
>>>>> So you need that html-like program style even when not
>>>>> running within a web-server environment ?
>>>>
>>>> <?php ?> is not particular HTML like, but yes PHP requires those
>>>> to indicate code as opposed to literal text.
>>>>
>>>> Given almost all PHP is web where literal text is common
>>>> unlike most other languages, then it is not so bad.
>>>>
>>>> > Well, why not a simple Python example at the same time
>>>>
>>>> Python does not have the same web percentage.
>>>>
>>>> Arne
>>>>
>>>
>>> That was not the point. The question was :
>>> >>>> Can PHP be used in a "standalone mode" to do what I want?
>>> and my point is that Python 1. is cleaner as stand-alone language
>>> and 2. has a lot of VMS "things" built-in in the current port.
>>>
>>> As a serverside, scripting tool, PHP might be better, but,
>>> as I said, that was not the question at hand.
>>>
>>>
>>>
>> Example of PHP in standalone mode (The HTML tags are hardcoded into the PHP
>> source):
>> $PHP -q APACHE$COMMON:[PHP.SCRIPTS]PHP_OPENVMS.PHP
>> <h1><center>Testing the OpenVMS extension</center></h1><br>
>> openvms_cvt_filename (OPENVMS_CVT_VMS_TO_UNIX,
>> "PHP_ROOT:[SCRIPTS]PHP_OPENVMS.PH
>> P") = <b>%SYSTEM-S-NORMAL, normal successful completion</b><br>
>> openvms_getdvi ("DISPLAY_DEVNAM") = TNA4:<br>
>> openvms_getjpi ("LAST_LOGIN_I") = 15-AUG-2011 10:33:58.68<br>
>> openvms_getsyi ("BOOTTIME") = 16-AUG-2011 03:57:14.00<br>
>> openvms_time () = 16-AUG-2011 19:10:11.57<br>
>> openvms_uptime () = 0 15:12:59<br>
>> <br>
>> <pre>
>> View of Cluster from system ID 65534 node: MIKE 16-AUG-2011 19:10:11
>> +-----------------------------+
>> | SYSTEMS | MEMBERS |
>> |-------------------+---------|
>> | NODE | SOFTWARE | STATUS |
>> |--------+----------+---------|
>> | MIKE | VMS V8.3 | |
>> +-----------------------------+
>> </pre>
>> <pre>
>> OpenVMS V8.3 on node MIKE 16-AUG-2011 19:10:11.60 Uptime 0 15:12:59
>> Pid Process Name State Pri I/O CPU Page flts Pages
>> 00000041 SWAPPER HIB 16 0 0 00:00:06.78 0 0
>> 00000044 LANACP HIB 14 71 0 00:00:00.31 170 21
>> 00000046 IPCACP HIB 10 9 0 00:00:00.07 53 26
>> 00000047 ERRFMT HIB 8 949 0 00:00:02.85 403 84
>> 00000049 OPCOM HIB 8 164 0 00:00:00.36 135 45
>> 0000004A AUDIT_SERVER HIB 10 87 0 00:00:00.34 125 160
>> 0000004B JOB_CONTROL HIB 10 488 0 00:00:00.74 123 55
>> 0000004D QUEUE_MANAGER HIB 10 119 0 00:00:00.44 205 92
>> 0000004E SECURITY_SERVER HIB 10 77 0 00:02:05.71 731 133
>> 0000004F ACME_SERVER HIB 10 70 0 00:00:24.55 640 66 M
>> 00000092 TCPIP$NTP_1 LEF 9 59160 0 00:00:58.87 930 177 N
>> 0000005A SMISERVER HIB 9 52 0 00:00:00.99 179 51
>> 00000061 TCPIP$INETACP HIB 10 489 0 00:00:01.43 282 122
>> 00000062 TCPIP$FTP_1 LEF 10 145 0 00:00:00.91 468 115 N
>> 00000064 TCPIP$POP_1 HIB 10 890 0 00:00:03.59 637 25 N
>> 00000065 SMTP_MIKE_01 HIBO 5 350 0 00:00:01.11 570 28
>> 00000068 MYSQL_SERVER HIB 5 83818 0 00:12:50.38 8388 2048 M
>> 00000069 APACHE$00 LEF 6 3334 0 00:00:39.69 1783 181
>> 0000006B QOTD_A LEF 16 358 0 00:00:01.26 1748 102
>> 0000012E APACHE$00001 COM 2 1814 0 00:57:17.52 12140 7131
>> 00000130 APACHE$00002 LEF 4 1833 0 00:00:24.82 1649 1821
>> 000000B1 Mike_R CUR 4 1177 0 00:00:06.97 3099 525
>> </pre>
>> $
>> Is that what you meant?
>>
>>
>
> Is "the OpenVMS extension" documentet somewhere ?
> I do not understand what is the script and what is the output.
>
> Is PHP_OPENVMS.PHP the script that runs this demo ?
> Or is it the "OpenVMS extension" as such ?
>
Apologizing for the verbiage:
Mike_$ty APACHE$COMMON:[PHP.SCRIPTS]PHP_OPENVMS.PHP
<?php
#
# Load the OpenVMS extension if needed
#
if (! extension_loaded ("openvms"))
dl ("php_openvms");
#
# Display the header
#
echo "<h1><center>Testing the OpenVMS extension</center></h1><br>\n";
#
# Allow only errors to be reported
#
error_reporting (E_ERROR);
#
# Test the OpenVMS convert filename function
#
# openvms_cvt_filename (func_code, file_name)
#
# func_codes:
# OPENVMS_CVT_VMS_TO_UNIX Convert vms filespec to unix filespec
# OPENVMS_CVT_UNIX_TO_VMS Convert unix filespec to vms filespec
#
$VmsFn = "PHP_ROOT:[SCRIPTS]PHP_OPENVMS.PHP";
$UnixFn = openvms_cvt_filename (OPENVMS_CVT_VMS_TO_UNIX, $VmsFn);
if ($UnixFn === FALSE)
echo "openvms_cvt_filename (OPENVMS_CVT_VMS_TO_UNIX, \"$VmsFn\") = <b>" . op
envms_message (openvms_status ()) . "</b><br>\n";
else
echo "openvms_cvt_filename (OPENVMS_CVT_VMS_TO_UNIX, \"$VmsFn\") = $UnixFn<b
r>\n";
#
# Test the OpenVMS getdvi function
#
# openvms_getdvi (item_code [,device_name])
#
# item_codes:
# <item_code> Any Item code supported by F$GETDVI
# "?" List of supported item codes
# device_name: Defaults to "TT"
#
$item = "DISPLAY_DEVNAM";
$val = openvms_getdvi ($item);
if ($val === FALSE)
echo "openvms_getdvi (\"$item\") = <b>" . openvms_message (openvms_status ()
) . "</b><br>\n";
else
echo "openvms_getdvi (\"$item\") = $val<br>\n";
#
# Test the OpenVMS getjpi function
#
# openvms_getjpi (item_code [,proc_name][,pid])
#
# item_codes:
# <item_code> Any Item code supported by F$GETJPI
# "?" List of supported item codes
# proc_name: Any process name
# pid: Any process ID or -1 wild card
#
$item = "LAST_LOGIN_I";
$val = openvms_getjpi ($item);
if ($val === FALSE)
echo "openvms_getjpi (\"$item\") = <b>" . openvms_message (openvms_status ()
) . "</b><br>\n";
else
echo "openvms_getjpi (\"$item\") = $val<br>\n";
#
# Test the OpenVMS getsyi function
#
# openvms_getsyi (item_code [,node_name][,csid])
#
# item_codes:
# <item_code> Any Item code supported by F$GETSYI
# "?" List of supported item codes
# node_name: Any node name
# csid: Any cluster system ID or -1 wild card
#
$item = "BOOTTIME";
$val = openvms_getsyi ($item, "", 0);
if ($val === FALSE)
echo "openvms_getsyi (\"$item\") = <b>" . openvms_message (openvms_status ()
) . "</b><br>\n";
else
echo "openvms_getsyi (\"$item\") = $val<br>\n";
#
# Test the OpenVMS time function
#
# openvms_time ([millisecond_time])
#
$val = openvms_time ();
if ($val === FALSE)
echo "openvms_time () = <b>" . openvms_message (openvms_status ()) . "</b><b
r>\n";
else
echo "openvms_time () = $val<br>\n";
#
# Test the OpenVMS uptime function
#
# openvms_uptime ()
#
$uptime = openvms_uptime ();
if ($uptime === FALSE)
echo "openvms_uptime () = <b>" . openvms_message (openvms_status ()) . "</b>
<br>\n";
else
echo "openvms_uptime () = $uptime<br>\n";
echo "<br>\n";
#
# Show the cluster info
#
ShowCluster ();
#
# Show the system info
#
ShowSystem ();
#
# Show Cluster
#
function ShowCluster ()
{
$SystemId = openvms_getsyi ("SCSSYSTEMID");
$NodeName = openvms_getsyi ("NODENAME");
$Time = strtok (openvms_time (), ".");
echo "<pre>\n";
$hdr = "View of Cluster from system ID $SystemId node: $NodeName";
$pad = str_repeat (" ", 79 - (strlen ($hdr) + strlen ($Time)));
echo $hdr . $pad . $Time . "\n";
echo "+-----------------------------+\n";
echo "| SYSTEMS | MEMBERS |\n";
echo "|-------------------+---------|\n";
echo "| NODE | SOFTWARE | STATUS |\n";
echo "|--------+----------+---------|\n";
$ctx = -1;
while (1)
{
$csid = openvms_getsyi ("NODE_CSID", "", &$ctx);
if ($csid === FALSE)
{
$status = openvms_status ();
if ($status != 2560)
echo openvms_message (openvms_status ()) . "<br>\n";
break;
}
$NodeName = str_pad (openvms_getsyi ("NODENAME", "", $csid), 6, " ", STR_PAD
_RIGHT);
$swtype = openvms_getsyi ("NODE_SWTYPE", "", $csid);
$swvers = openvms_getsyi ("NODE_SWVERS", "", $csid);
$software = str_pad ($swtype . $swvers, 8, " ", STR_PAD_RIGHT);
if (strcasecmp (openvms_getsyi ("CLUSTER_MEMBER", "", $csid), "TRUE") == 0)
$status = "MEMBER";
else
$status = " ";
echo "| $NodeName | $software | $status |\n";
}
if (openvms_getsyi ("CLUSTER_NODES") == 0)
{
$NodeName = str_pad (openvms_getsyi ("NODENAME"), 6, " ", STR_PAD_RIGHT);
$swtype = openvms_getsyi ("NODE_SWTYPE", "", $csid);
$swvers = openvms_getsyi ("NODE_SWVERS", "", $csid);
$software = str_pad ($swtype . $swvers, 8, " ", STR_PAD_RIGHT);
if (strcasecmp (openvms_getsyi ("CLUSTER_MEMBER", "", $csid), "TRUE") == 0)
$status = "MEMBER";
else
$status = " ";
echo "| $NodeName | $software | $status |\n";
}
echo "+-----------------------------+\n";
echo "</pre>\n";
}
#
# Show System (Requires World Privilege)
#
function ShowSystem ()
{
$VmsVer = trim (openvms_getsyi ("VERSION"));
$NodeName = openvms_getsyi ("NODENAME");
$UpTime = trim (openvms_uptime ());
$Time = openvms_time ();
echo "<pre>\n";
echo "OpenVMS $VmsVer on node $NodeName $Time Uptime $UpTime\n";
echo " Pid Process Name State Pri I/O CPU Page flts Pa
ges\n";
$ctx = -1;
while (1)
{
$pid = openvms_getjpi ("PID", "", &$ctx);
if ($pid === FALSE)
{
$status = openvms_status ();
if ($status != 2472)
echo openvms_message (openvms_status ()) . "<br>\n";
break;
}
$prcpid = str_pad ($pid, 8, " ", STR_PAD_RIGHT);
$prcnam = str_pad (openvms_getjpi ("PRCNAM", "", $pid), 15, " ", STR_PAD_RIG
HT);
$state = str_pad (openvms_getjpi ("STATE", "", $pid), 5, " ", STR_PAD_RIGHT)
;
$pri = str_pad (openvms_getjpi ("PRI", "", $pid), 3, " ", STR_PAD_LEFT);
$io = openvms_getjpi ("DIRIO", "", $pid) + openvms_getjpi ("BUFIO", "", $pid
);
$io = str_pad ($io, 9, " ", STR_PAD_LEFT);
$cputim = openvms_time (openvms_getjpi ("CPUTIM", "", $pid));
$pagflts = str_pad (openvms_getjpi ("PAGEFLTS", "", $pid), 9, " ", STR_PAD_L
EFT);
$pages = openvms_getjpi ("GPGCNT", "", $pid) + openvms_getjpi ("PPGCNT", "",
$pid);
$pages = $pages / (openvms_getsyi ("PAGE_SIZE") / 512);
$pages = str_pad ($pages, 6, " ", STR_PAD_LEFT);
$multithread = openvms_getjpi ("MULTITHREAD", "", $pid);
$owner = openvms_getjpi ("OWNER", "", $pid);
$mode = openvms_getjpi ("MODE", "", $pid);
if ($multithread >= 1)
$sts = "M";
else
$sts = " ";
if ($owner != 0)
$sts .= "S";
else
if (strcasecmp ($mode, "NETWORK") == 0)
$sts .= "N";
else
if (strcasecmp ($mode, "BATCH") == 0)
$sts .= "B";
else
$sts .= " ";
echo "$prcpid $prcnam $state $pri$io$cputim $pagflts $pages $sts\n";
}
echo "</pre>\n";
}
?>
Mike_$
--
Mike R.
Home: http://alpha.mike-r.com/
QOTD: http://alpha.mike-r.com/php/qotd.php
No Micro$oft products were used in the URLs above, or in preparing this message.
Recommended reading: http://www.catb.org/~esr/faqs/smart-questions.html#before
More information about the Info-vax
mailing list