cgi_passing_parameters
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | cgi_passing_parameters [2023/02/01 05:33] (current) – created hangar118 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Passing parameters to a CGI script ====== | ||
+ | |||
+ | Some important points: | ||
+ | |||
+ | * The CGI script has to end with .cgi in the name | ||
+ | |||
+ | * It can be placed anywhere in your folder '' | ||
+ | |||
+ | * It has to have secure web permissions set -- run '' | ||
+ | |||
+ | * CGI parameters are passed after ''?'' | ||
+ | |||
+ | * The CGI script gets the parameters via the environment variable '' | ||
+ | |||
+ | Example session: | ||
+ | |||
+ | < | ||
+ | |||
+ | # Folder for CGI scripts | ||
+ | $ mkdir ~/ | ||
+ | |||
+ | # Create file such a this | ||
+ | $ cat ~/ | ||
+ | # | ||
+ | echo ' | ||
+ | echo '' | ||
+ | echo '< | ||
+ | echo '< | ||
+ | echo '< | ||
+ | echo '</ | ||
+ | echo '< | ||
+ | |||
+ | echo '< | ||
+ | |||
+ | echo '< | ||
+ | |||
+ | echo "Query (after '?' | ||
+ | echo "From: ${HTTP_USER_AGENT}" | ||
+ | |||
+ | echo '</ | ||
+ | |||
+ | echo '</ | ||
+ | echo '</ | ||
+ | exit 0 | ||
+ | |||
+ | # Set executable attribute | ||
+ | $ chmod +x foo.cgi | ||
+ | |||
+ | # Set secure web permissions | ||
+ | $ mkhomepg | ||
+ | setting secure web permissions for / | ||
+ | % queing permissions to be set | ||
+ | |||
+ | # Correct permissions would look like this | ||
+ | $ ls -l ~/ | ||
+ | total 4.0K | ||
+ | -rwxr-x--- 1 hangar118 www-data 368 Jan 3 02:21 foo.cgi* | ||
+ | |||
+ | </ | ||
+ | |||
+ | It can be invoked via https:// | ||
+ | |||
+ | Then, in the browser it will produce an output similar to this: | ||
+ | |||
+ | < | ||
+ | |||
+ | Hello World! | ||
+ | |||
+ | Query (after '?' | ||
+ | From: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | NOTE: The example session is from the MetaArray | ||
cgi_passing_parameters.txt · Last modified: 2023/02/01 05:33 by hangar118