Quote:
Originally Posted by sharp859
I have some shell scripts with some options in the linux server in the home directory I need to run using the webpage in a single.
|
"In the home directory" means the webserver needs to be configured to run CGI scripts from there, and user the scripts should run as must be allowed to run those scripts. Also, please give example of what "some options" means here?
Quote:
Originally Posted by sharp859
I wonder if we can run the same webpage from windows also..
|
These scripts are run server-side, accessing them you do through the (HTML-rendered portion of) CGI script. Unless you intend to ignore standards HTML is not confined to one O.S. or browser.
Quote:
Originally Posted by sharp859
My idea is to execute a different shellscripts
|
If they are scripts that affect the system itself you better think trice.
Quote:
Originally Posted by sharp859
using a webpage
|
It'll look like a webpage but it's just part of the CGI script.
Quote:
Originally Posted by sharp859
single click means when I click particular shell name
|
If you can do with a flat HTML page that lists all scripts then the term "hyperlink" comes to mind ;-p
If you want input fields, tickboxes, radio buttons or drop-downs then you probably want to GET or POST data to a CGI.
Quote:
Originally Posted by sharp859
My view we can use perl-cgi or any fair suggession regarding this..
|
Sure, why not. Increase your Perl-fu and read something along the lines of
http://www.w3.org/Security/Faq/wwwsf4.html to make sure you're following best practices.
Here's a simple example in BaSH of calling an application called "vnstat" as a CGI. Apache is configured to only accept HTTPS, accepts CGIs in /var/www/cgi-bin and the user Apache runs as is allowed to execute vnstat through an /etc/sudoers entry:
Code:
#!/bin/bash -
# Purpose: Bash CGI for vnstat, args: QUERY_STRING, deps: Bash, GNU utils, run-from: httpd as cgi.
set -puePC; PROGNAME=${0//*\//}
function log() { /usr/bin/logger -i -p kern.err -t ${PROGNAME:="some unknown CGI"} "$@"; }
function header() { echo -en "Content-type: text/html\n\n<html><head><title>\n"; echo "Vnstat</title></head>"; }
function body() { echo "<body>"; }; function footer() { echo "</body></html>"; }
function form() { echo "<form name=\"q\" action=\"https://localhost:443/cgi-bin/vnstat.sh\" method=\"GET\">"
echo "<select name=\"q\">"
[ ${QUERY_STRING:2:1} -eq 1 ] 2>/dev/null && { selopt1="SELECTED"; }; echo "<option ${selopt1:=""} value=\"1\">Hourly</option>"
[ ${QUERY_STRING:2:1} -eq 2 ] 2>/dev/null && { selopt2="SELECTED"; }; echo "<option ${selopt2:=""} value=\"2\">Daily</option>"
[ ${QUERY_STRING:2:1} -eq 3 ] 2>/dev/null && { selopt3="SELECTED"; }; echo "<option ${selopt3:=""} value=\"3\">Weekly</option>"
[ ${QUERY_STRING:2:1} -eq 4 ] 2>/dev/null && { selopt4="SELECTED"; }; echo "<option ${selopt4:=""} value=\"4\">Monthly</option>"
[ ${QUERY_STRING:2:1} -eq 5 ] 2>/dev/null && { selopt5="SELECTED"; }; echo "<option ${selopt5:=""} value=\"5\">Top 10</option>"
echo "</select>"; echo "<input type=\"submit\">"; echo "</form>"; }
QUERY_STRING="${QUERY_STRING:0:3}"; if [ "${QUERY_STRING:0:2}" != "q=" ]; then header; body; form; footer
else case "${QUERY_STRING:2:1}" in 1) OPT="-h";; 2) OPT="-d";; 3) OPT="-w";; 4) OPT="-m";; 5) OPT="-t";;
*) header; body; form; footer;; esac; header; body; form; echo "<pre>"; umask 027; /usr/bin/sudo /usr/bin/vnstat "$OPT" 2>&1 || exit 127
echo "</pre>"; footer; fi; exit 0