vipsi - the friendly vip script interpreter

Example Scripts

CGI Scripts

Search Site

List functions: thisThis is Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
which i use for Flow control: if … then
Flow control: try … then
the
"Seach Site" form on little-bat.de. You will have to adapt some paths Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
it is, like all my Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi scripts
, complicated by Flow control: if … then
Flow control: try … then
the
fact, that i use it for two different sites without modification. So there is some path-fiddleing in there. It also contains a 'show-my-source' part.

Download link

search.cgi

Test link

Flow control: if … then
Flow control: try … then
The
Online Chat: Test links
Search Site: Test link
Print Environment: Test link
Online Z80 Assembler: Test link
Show Beautified Folder Listings: Test link
Sort-of-a Shell: Test link
test link
searches Flow control: if … then
Flow control: try … then
the
List functions: localslocal copy of little-bat.de for Flow control: if … then
Flow control: try … then
the
occurance of any List functions: words
Shell Immediate Commands: words
word
you like:

CGI Scripts: Search SiteSearch Site    

Listing

#!/home/smile77/bin/vipsi


// "CGI Scripts: Search Sitesearch site" Example Scripts: CGI Scripts
Example Scripts: Scripts
script
as used on my homepage // ------------------------------------------- // please adjust paths ... B-) // Flow control: if … then
Flow control: try … then
the
search pattern passed to Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
(must Numeric functions: existsexist): Flow control: if … thenif !Numeric functions: existsexists(pattern) Instructions: var
How does VScript::Value() work?: Var*&
var
pattern = "" Flow control: if … then
Flow control: try … then
then
// Text functions: file
Instructions: file
file
system Integer numbers: Base 256base expressed as http Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Text functions: file
Instructions: file
file
Instructions: var
How does VScript::Value() work?: Var*&
var
file_root = List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.DOCUMENT_ROOT # "/" Instructions: var
How does VScript::Value() work?: Var*&
var
http_root = "http://" # List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_NAME # "/" // little patch so i can use it Operators: Make Identifier "@"at home: Flow control: if … thenif List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_NAME=="_default_" http_root = "http://" # List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.HTTP_HOST # "/" Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_ADDR=="127.0.0.1" || List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_ADDR=="10.0.0.4" file_root #= "www/little-bat.de/" http_root #= "www/little-bat.de/" Flow control: if … then
Flow control: try … then
then
// http Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
html header: Instructions: putput "content-type: Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html",Constants: nlnl,Constants: nlnl Instructions: putput "<!doctype html public \"-//w3c//dtd html 4.01 strict//en\"><html><head>" Instructions: putput "<META http-equiv=Content-Type content='Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=UTF-8'>" Instructions: putput "<title>search results for '"#pattern#"'</title></head>",Constants: nlnl Instructions: putput "<body background='"#http_root#"b/hdgr.jpg' bgcolor='#CCCCCC' ", "Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
=black Text functions: link
Instructions: link
link
=black vlink=blue alink=black>",Constants: nlnl // test for magic parameter to show my own source: Flow control: if … thenif Numeric functions: existsexists showsource Instructions: var
How does VScript::Value() work?: Var*&
var
myfile = List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SCRIPT_FILENAME Instructions: var
How does VScript::Value() work?: Var*&
var
mysource = Text functions: file
Instructions: file
file
(myfile) Text functions: convert
Instructions: convert
convert
mysource to html Instructions: putput "<pre>",Constants: nlnl, mysource, Constants: nlnl,"</pre></body></html>",Constants: nlnl Flow control: end
Shell Immediate Commands: exit, quit, end
end
Flow control: if … then
Flow control: try … then
then
// Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedure
: Print usage Vipsi command syntax: Instructions
Instructions
Glossary: Instruction
instructions
Instructions: procproc DisplayHelp(errmsg) { put "<p align=center>&nbsp;", "<br><b>",errmsg,"</b>", "<br>&nbsp;", "<table border=1 width='95%' align=center cellpadding=2>", "<tr><Flow control: if … then
Flow control: try … then
th
align=center>", "Help for CGI Scripts: Search SiteSearch Site", "</Flow control: if … then
Flow control: try … then
th
></tr>",Constants: nlnl, "<tr><td align=center>", "<table border=0><tr><td>", "<ul>", "<li>Flow control: if … then
Flow control: try … then
The
search pattern must be Operators: Make Identifier "@"at least 3 characters long.</li>", "<li>Flow control: if … then
Flow control: try … then
The
search is Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
case sensitive.</li>", "<li>Flow control: if … then
Flow control: try … then
The
search pattern must Numeric functions: matchmatch exactly Flow control: if … then
Flow control: try … then
the
Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
in a Text functions: file
Instructions: file
file
.", "<br>Flow control: if … thenIf it contains multiple List functions: words
Shell Immediate Commands: words
words
, Flow control: if … then
Flow control: try … then
then
they must appear 'as written'.</li>", "<li>Use Flow control: if … then
Flow control: try … then
the
Operators: Multiply "*"wildcards '?' Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
'*' to Numeric functions: matchmatch any single character Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
", "<br>any sequence of non-significant characters.</li>", "</ul>", "</td></tr></table>", "</td></tr>",Constants: nlnl, "<tr><td align=center>", "e.g. to search for Text functions: file
Instructions: file
files
which contain '<b>foo</b>' Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
'<b>bar</b>' search for '<b>foo*bar</b>'.", "</td></tr></table>", "<p>&nbsp;",Constants: nlnl } // Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedure
: search all Text functions: file
Instructions: file
files
in directory "path" // Functions with varying return types: call
Instructions: call
calls
itself recursively for all subdirectories Instructions: procproc Search(path) { Flow control: if … thenif Text functions: rightstrrightstr(path,1)!="/" path#="/" Flow control: if … then
Flow control: try … then
then
Instructions: var
How does VScript::Value() work?: Var*&
var
folder = List functions: dir
Instructions: dir
Shell Immediate Commands: dir
dir
(file_root#path) Instructions: var
How does VScript::Value() work?: Var*&
var
i = 0 Flow control: do … loopdo Flow control: whilewhile ++i<=Numeric functions: countcount(folder) Instructions: var
How does VScript::Value() work?: Var*&
var
item = folder[i] Instructions: var
How does VScript::Value() work?: Var*&
var
dir: fnamefname = item.dir: fnamefname Flow control: if … thenif item.dir: flagsflags[1]=="d" && Text functions: rightstrrightstr(dir: fnamefname,1)!="/" dir: fnamefname#="/" Flow control: if … then
Flow control: try … then
then
Flow control: if … thenif dir: fnamefname[1]=="." Flow control: nextnext Flow control: if … then
Flow control: try … then
then
// skip hidden Text functions: file
Instructions: file
files
Flow control: if … thenif dir: fnamefname=="b/" Flow control: nextnext Flow control: if … then
Flow control: try … then
then
// skip images folders Flow control: if … thenif dir: fnamefname=="stats/" Flow control: nextnext Flow control: if … then
Flow control: try … then
then
// skip stats folder (Instructions: requirerequires password anyway) Flow control: if … thenif item.dir: flagsflags[1]=="d" // recursively handle folder Search(path#dir: fnamefname) Flow control: nextnext Flow control: if … then
Flow control: try … then
then
Instructions: var
How does VScript::Value() work?: Var*&
var
ext = dir: fnamefname[ Numeric functions: rfindrfind(dir: fnamefname,".") to ] Flow control: if … thenif !Numeric functions: findfind(".html.hh.cpp.txt",ext) Flow control: nextnext Flow control: if … then
Flow control: try … then
then
// no Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
Text functions: file
Instructions: file
file
Instructions: var
How does VScript::Value() work?: Var*&
var
datei = Text functions: lowerstrlowerstr(Text functions: file
Instructions: file
file
(file_root#path#dir: fnamefname)) files_scanned += 1 bytes_scanned += Numeric functions: countcount(datei) Flow control: if … thenif !Numeric functions: matchmatch(datei,pattern) Flow control: nextnext Flow control: if … then
Flow control: try … then
then
// Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
found Instructions: var
How does VScript::Value() work?: Var*&
var
a=Numeric functions: findfind(datei,"<title>") // found: display Text functions: file
Instructions: file
file
Instructions: var
How does VScript::Value() work?: Var*&
var
e=Numeric functions: findfind(datei,"</title>") Instructions: var
How does VScript::Value() work?: Var*&
var
title = a&&e ? datei[a+7 to e-1] : "<i>no title</i>" Display(path,dir: fnamefname,title) Flow control: do … looploop } // Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedure
: build a Text functions: link
Instructions: link
link
: Instructions: procproc Text functions: link
Instructions: link
Link
(url,Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
) { Flow control: returnreturn "<a href='" # url # "'>" # Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
# "</a>" } // Vipsi command syntax: Procedures
Data Types: Procedures
Glossary: Procedure
Procedure
: print table row for Text functions: file
Instructions: file
file
: Instructions: procproc Display(path,dir: fnamefname,title) { files_found++ Text functions: convert
Instructions: convert
convert
path to html Text functions: convert
Instructions: convert
convert
dir: fnamefname to html Instructions: var
How does VScript::Value() work?: Var*&
var
url = http_root # path # dir: fnamefname; Instructions: putput "<tr><td>", Text functions: link
Instructions: link
Link
(url,path#dir: fnamefname), "</td><td>", title, "</td></tr>",Constants: nlnl } // statistics counters Instructions: var
How does VScript::Value() work?: Var*&
var
files_scanned = 0 Instructions: var
How does VScript::Value() work?: Var*&
var
bytes_scanned = 0 Instructions: var
How does VScript::Value() work?: Var*&
var
files_found = 0 // print table start Instructions: putput "<p>&nbsp;<table border=1 width='95%' align=center cellpadding=2>", "<tr><Flow control: if … then
Flow control: try … then
th
bgcolor='#ffffcc' colspan=2 align=center style='font-size:150%;'>Search results for '", pattern, "'</Flow control: if … then
Flow control: try … then
th
></tr>", "<tr><Flow control: if … then
Flow control: try … then
th
bgcolor='#00CCCC'>Text functions: file
Instructions: file
file
</Flow control: if … then
Flow control: try … then
th
><Flow control: if … then
Flow control: try … then
th
bgcolor='#00CCCC'>title</Flow control: if … then
Flow control: try … then
th
></tr>\n" // search & print table rows Flow control: if … thenif Numeric functions: countcount(pattern)>=3 pattern = "*" # Text functions: lowerstrlowerstr(pattern) # "*" Search("") Flow control: if … then
Flow control: try … then
then
// print table Flow control: end
Shell Immediate Commands: exit, quit, end
end
Instructions: putput "</table>",Constants: nlnl // Flow control: if … thenif no Text functions: file
Instructions: file
files
found print additional help Flow control: if … thenif files_found Instructions: putput "<p align=center>&nbsp;", "<br>Scanned ",files_scanned, " Text functions: file
Instructions: file
files
(",bytes_scanned, " bytes) Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
found <b>",files_found, "</b> Text functions: file
Instructions: file
file
","s"[to files_found>1],".</p>\n" Flow control: if … then
Flow control: try … then
else
Flow control: if … thenif Numeric functions: countcount(pattern)==0 DisplayHelp("Search failed. (no search pattern given)") Flow control: if … then
Flow control: try … then
else
Flow control: if … thenif Numeric functions: countcount(pattern)<3 DisplayHelp("Search failed. (search pattern too short)") Flow control: if … then
Flow control: try … then
else
DisplayHelp("No Text functions: file
Instructions: file
files
found."); Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
then
// print Text functions: info
Shell Immediate Commands: info
info
on vipsi Instructions: putput "<p>&nbsp;", "<table border=1 width='95%' align=center cellpadding=2>", "<tr><td align=center>\n", Text functions: link
Instructions: link
Link
( "http://" # List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.HTTP_HOST # List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SCRIPT_NAME # "?showsource=yes", "view Example Scripts: CGI Scripts
Example Scripts: Scripts
script
" ), " &nbsp; powered by vipsi - vipsi shell Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
language &nbsp; ", Text functions: link
Instructions: link
Link
( "http://vipsi.sourceforge.net' target='_blank","Introduction: About vipsiabout vipsi" ), "\n</td></tr></table>\n" // print Flow control: end
Shell Immediate Commands: exit, quit, end
end
of html page Instructions: putput "<p>&nbsp;</body></html>",Constants: nlnl Flow control: end
Shell Immediate Commands: exit, quit, end
end

Valid HTML   Valid CSS