Thats me up & running now - thanks for your help guys, I'll certainly poke around those CGI vars.<br><br><div class="gmail_quote">On 19 May 2010 14:19, Carsten Bager <span dir="ltr"><<a href="mailto:carsten@beas.dk">carsten@beas.dk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">> How do i get command line vars? i tried GetENV() but it didn't understand GetEnv() (which unit is<br>
> it in?)<br>
<br>
<br>
</div>Here is a small cgi program. Comments are in Danish but I hope you can get the meaning.<br>
Carsten<br>
<br>
<br>
{Program version 1.00}<br>
program listdir2html;<br>
{LONGSTRINGS OFF}<br>
<br>
{$INFO +---------------------------------+}<br>
{$INFO | Statistik projekt til Oegendahl |}<br>
{$INFO +---------------------------------+}<br>
<br>
uses<br>
dos,<br>
classes,<br>
uInit,<br>
sysutils, {System}<br>
uSpStatus,<br>
testbruger;<br>
<br>
var<br>
QUERY_STRING:shortstring;<br>
<br>
<br>
Procedure PrintHeader(title:shortstring);<br>
Begin<br>
Writeln('HTTP/1.0 200 OK');<br>
Writeln('Server: Netscape-Communications/3.0');<br>
Writeln('Content-type: text/html');<br>
Writeln;<br>
Writeln;<br>
Writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');<br>
Writeln('<html>');<br>
Writeln(' <head>');<br>
Writeln(' <meta content="text/html;charset=windows-1252" http-equiv="Content-Type">');<br>
Writeln(' <title>',title,'</title>');<br>
Writeln(' </head>');<br>
Writeln(' <body>');<br>
Writeln(' <table style="background-color: rgb(153, 153, 153); text-align: center; width:<br>
100%;" border="0" cellpadding="2" cellspacing="2">');<br>
Writeln(' <tbody>');<br>
Writeln(' <tr>');<br>
Writeln(' <td style="font-size: 30px; font-weight: bold;">');<br>
Writeln(' ',cFaellesOverskrift);<br>
Writeln(' </td>');<br>
Writeln(' </tr>');<br>
Writeln(' </tbody>');<br>
Writeln(' </table>');<br>
Writeln(' <h2>');<br>
Writeln(' ',title);<br>
Writeln(' </h2>');<br>
End;<br>
<br>
Procedure PrintFooter;<br>
Begin<br>
Writeln(' </p>');<br>
Writeln(' </body>');<br>
Writeln('</html>');<br>
End;<br>
<br>
<br>
Procedure FindOgListFiler(title,PartFileName:shortstring);<br>
var<br>
Info:TSearchRec;<br>
flist:tstringlist;<br>
p:integer;<br>
date,s:shortstring;<br>
Begin<br>
flist:=tstringlist.create;<br>
If FindFirst (PartFileName,faAnyFile,Info)=0 then {Find f°rste fil}<br>
begin<br>
Repeat<br>
flist.add(Info.Name); {Find de f°lgende filer}<br>
Until FindNext(info)<>0;<br>
end;<br>
flist.sort; {Soter filer}<br>
p:=flist.count;<br>
while p<>0 do {Print fil navn til HTML side}<br>
begin<br>
dec(p);<br>
s:=flist.Strings[p];<br>
date:=copy(s,succ(length(QUERY_STRING)),12);<br>
date:=title+<br>
copy(date,1,4)+<br>
' d. '+copy(date,7,2)+<br>
'/'+copy(date,5,2)+<br>
' Kl. '+copy(date,9,2)+<br>
':'+copy(date,11,2);<br>
<br>
// WriteLn('<a href="../log/',s,'">',date,'</a>');<br>
WriteLn('<INPUT TYPE="BUTTON" VALUE="',date,'"<br>
ONCLICK="window.location.href=''http:','../log/',s,'''"><br>');<br>
flist.delete(pred(flist.count));<br>
end;<br>
flist.free;<br>
End;<br>
<br>
begin<br>
if not uSpStatus.InitShaerdMemory(InitShaerdMemoryStr,false) then<br>
begin<br>
PrintHeader('Beas login');<br>
writeln ('Kan ikke initialisere shared memory<br>');<br>
PrintFooter;<br>
halt;<br>
end;<br>
if not ErBrugerOk then<br>
halt(1);<br>
QUERY_STRING:=getenv('QUERY_STRING');<br>
if debug.Listdir2html then<br>
begin<br>
writeln(stderr);<br>
writeln(stderr,'QUERY_STRING= ',QUERY_STRING);<br>
end;<br>
chdir('..');<br>
if pos('Statistik',QUERY_STRING)<>0 then<br>
begin<br>
PrintHeader('Historiske statistik data fra blandeanlµg');<br>
FindOgListFiler('Statistik fil fra ','./log/statistik*.html');<br>
PrintFooter;<br>
end;<br>
if pos('Blandelog',QUERY_STRING)<>0 then<br>
begin<br>
PrintHeader('Historiske log data fra blandeanlµg');<br>
FindOgListFiler('Log fil fra ','./log/blandelog*.html');<br>
PrintFooter;<br>
end;<br>
if pos('Program',QUERY_STRING)<>0 then<br>
begin<br>
PrintHeader('Historiske program data fra blandeanlµg');<br>
FindOgListFiler('Program fil fra ','./log/program*.html');<br>
PrintFooter;<br>
end;<br>
if pos('AlarmLog',QUERY_STRING)<>0 then<br>
begin<br>
PrintHeader('Historiske alarm log data fra blandeanlµg');<br>
FindOgListFiler('Alarm log fil fra ','./log/alarmlog*.html');<br>
PrintFooter;<br>
end;<br>
end.<br>
<div><div class="h5"><br>
<br>
<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/mailman/listinfo/fpc-pascal</a><br>
</div></div></blockquote></div><br>