#!/usr/bin/env python3
#=====================================================================================
# List all environment variables 
#=====================================================================================
import os                                        #import os and cgi modules 

print("Content-Type: text/html \n")              #required cgi header

print("""
    <html>
    <body bgcolor=lightyellow>
    <h2>The Environment Variable PATH_INFO</h2>
    <br><br>
""")

try:
    params = os.environ["PATH_INFO"] or ""
except:
    params = ""

if not params :
    print("Click on <a href=env_path_info.cgi/Sam/Sultan> env_path_info.cgi/Sam/Sultan </a>") 
else:
    print(F"Your PATH_INFO parameter is: <b> {params} <br>") 
    print("<br><table border=1>") 
    params    = params[1:]					        #get rid of leading /
    paramList = params.split('/')				    #split on any additional /
    for param in paramList :
        print(F"<tr><td><b> {param} </td> ")
    print("</table>")




#=== link to see the python code =================================================
import os, sys
sys.path.insert(0,'/home/staff/sultan/public_html/cgi-bin/python')
import zCode                          #import func to display the Python code
filename = os.path.abspath(__file__)  #get absolute file name 
zCode.display(filename)               #call it
#=================================================================================