lazna -
Joined: 16 Aug 2015 Posts: 52
|
Posted: Wed Aug 26, 2015 11:19 am Post subject: image as a script output |
|
|
Writing web monitoring to monitor network boxes in windows shell used as CGI. CGI script call pinger.cmd which ping box with given IP address, create status picture and sent it into stdout. It does work if script is started on shell console (flush few lines of messed characters, content of 3kb picture) but no picture is displayed if such script was called from CGI wrapper. See here:
http://monitor.protonet.cz/updown/updown_ng/updown_ng.cmd
Older version of CGI warepper calling similar Perl script ( http://www.steveshipway.org/software/f_updown.html ) which work fine but quite slow. See here:
http://monitor.protonet.cz/updown/
Where could be problem with no picture display? Pinger uses convert.exe from Imagemagick package as a picture generator, instead of "imagename.png" using "png:-" to send image into stdout instead of save it to file.
CGI code:
==================================================================
@echo off
echo Content-Type: text/html
echo.
REM echo ^<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"^>
echo ^<HTML^>
echo ^<HEAD^>
echo ^<meta http-equiv="Content-Type" content="text/html; charset=utf-8"^>
REM echo ^<link rel="icon" href="pictures\favicon.png"^>
echo ^<title^>
echo Přehled nodů
echo ^</title^>
echo ^</head^>
echo ^<body^>
REM == START Define imagemap
REM echo ^<map name="default"^>
REM echo ^<area shape="rect" coords="0,0,120,20" href="hostname.htm" alt="Hostname"^>
REM echo ^<area shape="rect" coords="120,0,160,20" href="latency.htm" alt="Latency"^>
REM echo ^<area shape="rect" coords="0,20,160,40" href="ipaddr.htm" alt="IP address"^>
REM echo ^</map^>
REM == END define imagemap
echo ^<h1^>^<center^>Rychlę přehled dostupnosti nodů - VERZE 2^</center^>^</h1^>
echo ^<table^>
echo ^<tr^>
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1,2 delims=|" %%a in ('..\..\monitoring\utilities\sqlite3.exe ..\..\monitoring\db\boxes.db "SELECT ip_addr,devname FROM boxes"; ^| sort') do (
set /a counter=!counter!+1
if "!counter!"=="7" (
echo ^</tr^>
echo ^<tr^>
echo ^<td^>
echo ^<img src="http://monitor.protonet.cz/updown/updown_ng/pinger.cmd?host=%%a" alt="%%a"^>
echo ^</td^>
set counter=0
) else (
echo ^<td^>
echo ^<img src="http://monitor.protonet.cz/updown/updown_ng/pinger.cmd?host=%%a" alt="%%a"^>
echo ^</td^>
)
)
endlocal
echo ^</tr^>
echo ^</table^>
echo ^</body^>
echo ^</html^>
===================================================================================== |
|