Wrapping a bash script for CGI


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wrapping a bash script for CGI
# 1  
Old 07-11-2003
Wrapping a bash script for CGI

I hope its ok to start a new thread, I was going to use my existing one but thought a new one would better clarify things and provide better search for future reference.

Well I have my bash program working now, all nice, user input validated, output formatted, everything is looking sexy.

Now the guys tell me that they don't want telnet access to the server, grrrrrrr! I have to make
an idiot proof web interface.

So I need to choose a way to go. As I see it I can either re-write the whole thing in perl or
somehow 'wrap' my bash into a cgi interface.

I've been thinking about the latter option and it seems non-trivial to me at this stage. On the face of it my thinking goes something like this pseudocode:

1) Spawn a copy of my bash script and background it&
while[1] do
2) Take the standard output of the script and redirect it to a little HTML wrapper something like
echo "content-type: text\/html \<html\> <body>
$MYSTDOUTHERE \</html\>\</body\>"
3) process a POST request and send the relevant data to my backgrounded script
done

While I can express the concept clearly enough (I hope) the details are a bit fuzzy and I would welcome any input or comments before getting started. Is such a method possible/reliable/secure?
The web interface would only be used by trusted administrators but I am worried enough about 'command substitution' in any situation where CGIs are involved, its my natural paranoid stance Smilie
all best regards
Andy
# 2  
Old 07-11-2003
I think this is not secure in any case. I don't really understand why your users don't like telnet/ssh. A telnet bash session has completion, history and all goodies a Web-based one won't have. Typing commands in a Web page and a telnet session -- what makes the difference? Moreover, it's slow. manpages doesn't display well, for example.

If they really want it Web-based, consider a Java telnet/ssh client like http://javassh.org/

If they only need to carry out some predefined tasks, I think you may give them a Web interface with some menu options which execute the commands for them. But to have a command line directly attached to the Web is a very dangerous idea I can think of even if the user community is trusted.
# 3  
Old 07-16-2003
Java web interface for telnet will be good

Thanks cbkihong. I worked out how to do it but its really very ugly. Your idea of the JavaWeb telnet interface seems like the perfect political compromise and that is the method I am going with.
All good wishes
Andy
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Calling bash script from CGI

Hi, I am having two individual scripts Script 1): CGI script - is a simple script which trigger bash script Script 2): Bash script - is a script which execute which collects file system utilization information from all the Unix servers If I am executing CGI script manually from command... (2 Replies)
Discussion started by: Naveen.6025
2 Replies

2. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

3. Web Development

problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.

Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect. Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is redirected to welcome page. My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies

4. Homework & Coursework Questions

Run Program from Bash CGI-Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is a problem I am having with my 2 semester senior project. I have a LAMP server running Ubuntu 9.10 with... (8 Replies)
Discussion started by: JMooney5115
8 Replies

5. Shell Programming and Scripting

Delete Files with CGI Bash Script

Hi. I could use some help with my problem. I am creating a website. One option on this website is to delete a specified file, say an image, when the user clicks on it. I want to do this with CGI. I believe bash will be the easiest since I will just type the command "rm file". I also do not know... (4 Replies)
Discussion started by: JMooney5115
4 Replies

6. UNIX for Dummies Questions & Answers

bash history and command line wrapping

By default, we use ksh (88) as our shell. I prefer bash, so I added this line to my .profile: exec bash -o viI also added this to my .bashrc?: #*********************************************** #These are important tweaks specific to BASH: #***********************************************... (1 Reply)
Discussion started by: mrwatkin
1 Replies

7. Shell Programming and Scripting

Perl cgi script to call bash script?

Novice to perl here. I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on. Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
Discussion started by: pleonard
0 Replies

8. Shell Programming and Scripting

find command and wrapping in the script

Hello, I've been trying to use find command to find and print out some files. When I execute the command on the command line I get the output as expected howerver when I run it in the script it doesn't wrap. For example, this is nicely wraped find /etc -perm -o=w -exec ll '{}' \;... (4 Replies)
Discussion started by: mirusko
4 Replies

9. Shell Programming and Scripting

Wrapping ksh script

Hi folks, We want to protect our ksh scripts from our customers.We don't want to let them the option to viewor modify the scripts. Is there a way ro wrap a ksh script? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

10. Shell Programming and Scripting

CGI passing arrays/hashes to another CGI script

If I have a Perl CGI script (script01), which fills an array(s) with information and outputs a HTML page with a link to another CGI page (script02); is there anyway to pass the array(s) from "script01" to "script02" when the page visitor clicks the link? Hope that makes sense! :) (2 Replies)
Discussion started by: WIntellect
2 Replies
Login or Register to Ask a Question