Using CGI and BOS
It’s pointless to create a completely new concept of web in bash while there are other well-known implementations, for example Bash On Steroids
Fiction supports CGI scripts and includes fiction.serveCGI function for CGI routes
Using Bash On Steroids
Section titled “Using Bash On Steroids”-
Download Bash On Steroids and example index
Terminal window wget https://raw.githubusercontent.com/tinoschroeter/bash_on_steroids/master/build.shwget https://raw.githubusercontent.com/tinoschroeter/bash_on_steroids/master/index.htsh -
Run the builder
Terminal window bash build.shThis should create an index.cgi file in /usr/lib/cgi-bin
-
Add CGI route
Open your main file (index.shx by default) and add simple HTML route:
index.shx fiction.serveCGI "/usr/lib/cgi-bin/index.cgi" "/cgi" "text/html" -
Start the server
Terminal window fiction runFiction would automatically load and execute the main file with
bashxTerminal window bash index.shxYou can also use bashx directly to start the file
Terminal window bashx index.shx -
Verify that it works Open your server’s URL in the browser and add
/cgito open CGI route
Using other CGI scripts
Section titled “Using other CGI scripts”It’s pretty straightforward, make your script executable
chmod +x /path/to/scriptand add route:
FictionServeCGI "/path/to/script" "/cgi" "text/html"For all CGI features visit FictionServeCGI