LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-01-2008, 07:10 PM   #1
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Rep: Reputation: 0
Lightbulb How to design a fron end to run different shell script?


Hello all,
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.

Using radio button or similar!!
I appreciate if any one can send me a sample design and how to make it run .

my email id is sharp859@gmail.com
I wonder if we can run the same webpage from windows also..

Cheers,
pravin
 
Old 05-01-2008, 07:36 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
first off... what does "run using the webpage in a single" mean?

secondly, what language are you using or have you chosen one? What languages can you run if one isn't chosen?

running shell scripts from a web page is fairly trivial, but we at least need to know what language you're using so we can point you in the right direction.

... and it's preferred that the entire discussion take place here rather than in an email so others with the same question can learn from this answer.
 
Old 05-01-2008, 11:14 PM   #3
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
Regarding webpage design

Ya thanks for replying,
okay we will discuss here only.

My idea is to execute a different shells cripts of having around more than 300 lines on on average,using a webpage browser.single click means when I click particular shell name (using radio buttons may be)my script should run thats all about!!
My shell scripts will be in the linux servers

My view we can use perl-cgi or any fair suggession regarding this..
 
Old 05-02-2008, 06:29 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,953
Blog Entries: 54

Rep: Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732
Quote:
Originally Posted by sharp859 View Post
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 View Post
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 View Post
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 View Post
using a webpage
It'll look like a webpage but it's just part of the CGI script.


Quote:
Originally Posted by sharp859 View Post
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 View Post
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
 
Old 05-03-2008, 12:30 AM   #5
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
Ya regarding webpage design to run shell script

Thanks,
Ya options means myshell script -t argument these argument shd be user input

I got that point about configuring the server..

can some one provide script sample or structure to invoki .sh files from that server .

~Pravin
 
Old 05-03-2008, 06:52 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,953
Blog Entries: 54

Rep: Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732
Quote:
Originally Posted by sharp859 View Post
Ya options means myshell script -t argument these argument shd be user input
One of the ground rules of whatever it is you're sposed to be doing is to never trust user input.


Quote:
Originally Posted by sharp859 View Post
can some one provide script sample or structure to invoki .sh files from that server .
With a little bit of understanding BaSH scripts my example would do just that. If you don't understand it I suggest you go read some scripting guides like http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html and http://www.tldp.org/LDP/Bash-Beginne...tml/index.html. Or if you want to do Perl, as you said previously, you'll have to find some tutorials for that. And reading http://www.w3.org/Security/Faq/ should be considered mandatory. If you're new at scripting and your handiwork would go on a publicly accessable production host with untrusted users I'd suggest you don't, but instead look for a ready-made application. Because the risk of you fscking up is just to big (as evidenced by the type of questions you ask).

Note LQ can and is willing to help you accomplish your goals. But we shouldn't be asked to do your work for you. Even if we did then without having knowledge you wouldn't know how to assess its value (or vulnerability) or fix things anyway. So please go and read, experiment, post (pseudo-)code we can comment on, but don't ask for handouts.
 
Old 05-03-2008, 11:09 PM   #7
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
Is there any thing related to webpage send me the doccument or link I hardly need about perl or Bash scripting links or doccument..

Thanks for details
 
Old 05-03-2008, 11:30 PM   #8
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

There's some pretty good advice about that here:

http://www.w3.org/Security/Faq/wwwsf3.html#SVR-Q3

Hope that helps

, Mike
 
Old 05-05-2008, 07:23 PM   #9
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
For Perl try search.cpan.org and ask for CGI.pm
There are lots of other CGI related modules
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict a Shell Script to run from a shell bharaniks Linux - Security 7 08-26-2007 10:57 PM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM
Bash script - to save and run a command at the end satimis Programming 15 11-02-2004 08:53 AM
Shell script to run pl/sql script. colly Linux - General 1 09-09-2004 06:49 AM


All times are GMT -5. The time now is 11:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration