vipsi - the friendly vip script interpreter

Example Scripts

CGI Scripts

Print Environment

One of Flow control: if … then
Flow control: try … then
the
most basic Example Scripts: CGI Scripts
Example Scripts: Scripts
scripts
used everywhere. Numeric functions: nowNow also available as a vip Example Scripts: CGI Scripts
Example Scripts: Scripts
script
. It shows Flow control: if … then
Flow control: try … then
the
command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
, cgi Vipsi command syntax: Arguments
Glossary: Arguments
arguments
, environment Glossary: Variable, var_refvariables Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
lists
some bin directories.

Download link

test.cgi

Test link

/cgi-bin/test.cgi

Listing

#!/home/smile77/bin/vipsi


/* --------------------------------------------------------------------------------------------

    Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi scripts
: method "Instructions: getGET": Vipsi command syntax: Arguments
Glossary: Arguments
arguments
are passed in Flow control: if … then
Flow control: try … then
the
environment Glossary: Variable, var_refvariable "QUERY_STRING". method "POST": Vipsi command syntax: Arguments
Glossary: Arguments
arguments
are passed via Constants: stdinstdin. size of input data is passed in "CONTENT_LENGTH". common: Flow control: if … then
Flow control: try … then
the
Vipsi command syntax: Arguments
Glossary: Arguments
argument
Data Types: Text
Text functions: string
string
consists of multiple fields which are separated by ampersands "&". each field has (should have) Flow control: if … then
Flow control: try … then
the
form: "Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
=Glossary: Valuevalue". Flow control: if … then
Flow control: try … then
the
data is encoded according to mime type "application/x-www-form-urlencoded". List functions: thisthis means: spaces " " are replaced by Operators: Add "+"plus signs "+" Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
special characters are represented by their Text functions: hexstrhex code a la "%AF". Flow control: if … then
Flow control: try … then
the
Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi script
must Instructions: writewrite a Text functions: file
Instructions: file
file
to Constants: stdoutstdout. in Flow control: if … then
Flow control: try … then
the
most common case List functions: thisthis is a html Text functions: file
Instructions: file
file
: step 1: http-header: "content-type: Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html\n\n" Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
"content-type: Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=utf-8\n\n" Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
the
html page itself. it has Flow control: if … then
Flow control: try … then
the
following basic layout: <!doctype html public "-//w3c//dtd html 4.01 transitional//en"> <html> <head> <title>Titel der Seite ist Pflicht</title> <META http-equiv=Content-Type content="Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=UTF-8"> ((opt.)) </head> <body> <!-- Contents of page here --> </body> </html> --------------------------------------------------------------------------------------------- */ // print all Flow control: if … then
Flow control: try … then
the
headers: // http header // head section of html page Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
// start body section Instructions: putput "content-type: Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=utf-8\n\n", "<!doctype html public \"-//w3c//dtd html 4.01 transitional//en\">\n", "<html>\n", "<head>\n", "<META http-equiv=Content-Type content=\"Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
/html; charset=UTF-8\">\n", "<title>vipsi test Example Scripts: CGI Scripts
Example Scripts: Scripts
script
for cgi'</title>\n", "</head>\n", "<body style='font-family:sans-serif;'>\n", "<h2>*** vipsi *** cgi test Example Scripts: CGI Scripts
Example Scripts: Scripts
script
</h2>\n" // check whether Flow control: if … then
Flow control: try … then
the
"magic parameter" is passed to show my own source: // List functions: thisthis magic parameter is see_source=yes // Flow control: if … thenif so, show source as preformatted Data Types: Text
Item selector "[]": Text
Glossary: text, text_val
text
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Shell Immediate Commands: exit, quit, endquit Flow control: if … thenif Numeric functions: existsexists see_source Flow control: if … thenif see_source[1]=="y" || see_source[1]=="1" Flow control: if … thenif Numeric functions: existsexists List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SCRIPT_FILENAME 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) Flow control: if … then
Flow control: try … then
else
Instructions: var
How does VScript::Value() work?: Var*&
var
mysource = "erm ... error error ... SCRIPT_FILENAME is not set in Flow control: if … then
Flow control: try … then
the
process environment ..." Flow control: if … then
Flow control: try … then
then
Text functions: convert
Instructions: convert
convert
mysource to html Instructions: putput "<pre>\n", mysource, "\n</pre></body></html>\n" Flow control: end
Shell Immediate Commands: exit, quit, end
end
Flow control: if … then
Flow control: try … then
then
Flow control: if … then
Flow control: try … then
then
// print notification on what Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
Flow control: do … loopdoes // how to Functions with varying return types: call
Instructions: call
call
it Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
// how to Functions with varying return types: call
Instructions: call
call
it so that it print's it's own source Flow control: if … thenif Numeric functions: existsexists List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_NAME && Numeric functions: existsexists List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SCRIPT_NAME { Instructions: var
How does VScript::Value() work?: Var*&
var
mydomain = List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SERVER_NAME Instructions: var
How does VScript::Value() work?: Var*&
var
myurlpath = List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
.SCRIPT_NAME Instructions: var
How does VScript::Value() work?: Var*&
var
myurl = "http://" # mydomain # myurlpath Instructions: putput "<p>List functions: thisthis Example Scripts: CGI Scripts
Example Scripts: Scripts
script
Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
lists
environment Glossary: Variable, var_refvariables, command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
Instructions: getget/post cgi parameters.", "<p>to see Flow control: if … then
Flow control: try … then
the
source <a href='test.cgi?see_source=yes'>click here</a>.", "<p>you can Functions with varying return types: call
Instructions: call
call
it directly: ", myurl, "<br>Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
with some Vipsi command syntax: Arguments
Glossary: Arguments
arguments
: ", myurl, "?anton=123&amp;berta=wetter", "<br>Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
you can Instructions: writewrite an own page with a form which Functions with varying return types: call
Instructions: call
calls
List functions: thisthis Example Scripts: CGI Scripts
Example Scripts: Scripts
script
;-)." } Flow control: if … then
Flow control: try … then
then
// print List functions: globals
Shell Immediate Commands: globals
global
Glossary: Variable, var_refvariables // Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
can access all List functions: globals
Shell Immediate Commands: globals
global
Glossary: Variable, var_refvariables unknowing their Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
by accessing Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
list
Glossary: Variable, var_refvariable "List functions: globals
Shell Immediate Commands: globals
globals
". // command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
passed to Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
come first Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
are unnamed // (a Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi script
is normally Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
passed any command line Vipsi command syntax: Arguments
Glossary: Arguments
arguments
) // data from Flow control: if … then
Flow control: try … then
the
CGI Instructions: getGET/POST request come Flow control: nextnext Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
are named Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
already unencoded // Flow control: if … thenif bogus data is passed vipsi - the friendly one.: The namethe names may be weird Operators: Boolean Or with Variable "||="
Operators: Bitwise Or with Variable "|="
Operators: Bitwise Or "|"
Operators: Boolean Or "||"
or
unnamed // typically a Modes of Operation: CGI Scripts
Example Scripts: CGI Scripts
cgi script
should already know vipsi - the friendly one.: The namethe names of Vipsi command syntax: Arguments
Glossary: Arguments
arguments
passed to it // but List functions: thisthis cgi test Example Scripts: CGI Scripts
Example Scripts: Scripts
script
Flow control: do … loopdoes Operators: Bitwise Not "~"
Operators: Boolean Negation "!"
not
Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
must examine Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
names
'by hand'. Instructions: var
How does VScript::Value() work?: Var*&
var
argc = Numeric functions: countcount globals-1 Flow control: if … thenif argc { Instructions: putput "<h4>argv[] Vipsi command syntax: Arguments
Glossary: Arguments
arguments
</h4>\n", "<table border width='100%'><tr><td width='10%'><b>Numeric functions: indexindex</b></td>", "<td width='20%'><b>Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
</b></td><td><b>Glossary: Valuevalue</b></td></tr>\n" Instructions: var
How does VScript::Value() work?: Var*&
var
i = 0 Flow control: do … loopdo Flow control: whilewhile ++i<=argc Instructions: var
How does VScript::Value() work?: Var*&
var
gname = Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
List functions: globals
Shell Immediate Commands: globals
globals
[i] Instructions: var
How does VScript::Value() work?: Var*&
var
gdata = List functions: globals
Shell Immediate Commands: globals
globals
[i] Text functions: convert
Instructions: convert
convert
gname to printable; Text functions: convert
Instructions: convert
convert
gname to html Text functions: convert
Instructions: convert
convert
gdata to printable; Text functions: convert
Instructions: convert
convert
gdata to html Instructions: putput "<tr>" Instructions: putput "<td>List functions: globals
Shell Immediate Commands: globals
globals
[",i,"]</td>" Instructions: putput "<td>", gname=="" ? "<i>unnamed Glossary: Variable, var_refvariable</i>" : gname, "</td>" Instructions: putput "<td>", gdata, "</td>" Instructions: putput "</tr>" Flow control: do … looploop Instructions: putput "</table>\n" } Flow control: if … then
Flow control: try … then
then
// CGI Scripts: Print Environmentprint environment Glossary: Variable, var_refvariables // Flow control: if … then
Flow control: try … then
the
Example Scripts: CGI Scripts
Example Scripts: Scripts
script
can request Flow control: if … then
Flow control: try … then
the
process environment Glossary: Variable, var_refvariables with Flow control: if … then
Flow control: try … then
the
built-in Vipsi command syntax: Functions
Functions
Glossary: Function
function
List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
. // Flow control: if … then
Flow control: try … then
the
returned Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
list
contains one named item per environment Glossary: Variable, var_refvariable // Flow control: if … then
Flow control: try … then
the
CGI Instructions: getGET Vipsi command syntax: Arguments
Glossary: Arguments
arguments
can be found in Flow control: if … then
Flow control: try … then
the
Glossary: Variable, var_refvariable "QUERY_STRING" { Instructions: putput "<h4>List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
environment Glossary: Variable, var_refvariables</h4>\n", "<table border width='100%'><tr><td width='10%'><b>Numeric functions: indexindex</b></td>", "<td width='20%'><b>Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
</b></td><td><b>Glossary: Valuevalue</b></td></tr>\n" // in order to Instructions: sortsort by Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
we Text functions: convert
Instructions: convert
convert
Flow control: if … then
Flow control: try … then
the
named items of List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
// into sub-lists of form { Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
, data } Instructions: var
How does VScript::Value() work?: Var*&
var
env_var = List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
Instructions: var
How does VScript::Value() work?: Var*&
var
i = 0 Flow control: do … loopdo Flow control: whilewhile ++i <= Numeric functions: countcount env_var env_var[i] = { Vipsi command syntax: Identifiers (names)
Identifiers, names
Operators: Make Identifier "@"
Text functions: name
Glossary: Name, Identifier
name
env_var[i], env_var[i] } Flow control: do … looploop Instructions: sortsort env_var // Instructions: sortsort Flow control: if … then
Flow control: try … then
the
Data Types: Lists and arrays
Item selector "[]": Lists
Glossary: list, list_val
list
Text functions: convert
Instructions: convert
convert
env_var to printable // escape control characters et.al. Text functions: convert
Instructions: convert
convert
env_var to html // Text functions: convert
Instructions: convert
convert
'<' to '&lt;' etc. Instructions: var
How does VScript::Value() work?: Var*&
var
i = 0 Flow control: do … loopdo Flow control: whilewhile ++i <= Numeric functions: countcount env_var Instructions: var
How does VScript::Value() work?: Var*&
var
ename = env_var[i,1] Instructions: var
How does VScript::Value() work?: Var*&
var
edata = env_var[i,2] Instructions: putput "<tr>" Instructions: putput "<td>List functions: env
Shell Immediate Commands: env
Shell Immediate Commands: env
env
[",i,"]</td>" Instructions: putput "<td>", ename=="" ? "<i>unnamed Glossary: Variable, var_refvariable</i>" : ename, "</td>" Instructions: putput "<td>", edata, "</td>" Instructions: putput "</tr>\n" Flow control: do … looploop Instructions: putput "</table>\n" } // print misc. Text functions: info
Shell Immediate Commands: info
info
Instructions: putput "<h4>/bin/*</h4>\n" Instructions: putput "<pre>" Text functions: sys
Instructions: sys
sys
"ls","-l","/bin" Instructions: putput "<h4>/usr/bin/*</h4>\n" Instructions: putput "<pre>" Text functions: sys
Instructions: sys
sys
"ls","-l","/usr/bin" Instructions: putput "<h4>misc. tests</h4>" Instructions: putput "<pre>" Text functions: sys
Instructions: sys
sys
"which","gcc" Text functions: sys
Instructions: sys
sys
"which","make" // Flow control: if … then
Flow control: try … then
the
final closing tags // be nice Operators: Boolean And with Variable "&&="
Operators: Bitwise And with Variable "&="
Operators: Bitwise And "&"
Operators: Boolean And "&&"
and
terminate Flow control: if … then
Flow control: try … then
the
last line with a line ending character Instructions: putput "</body></html>\n" Flow control: end
Shell Immediate Commands: exit, quit, end
end

Valid HTML   Valid CSS