[SOLVED] Web page input executes on command line and output back to web page
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Web page input executes on command line and output back to web page
Hello everyone,
I have a simple grep task I want to make executable in my web browser. Here is the script:
from: ./grep-script.sh
Code:
#!/bin/bash
#
# Get input from user to grep in /home/user/test-file.txt
#
echo -n "Please enter grep input: "
read grepInput
grep $grepInput /home/user/test-file.txt
Instead of having going to the command line to run ./grep-script.sh, I want to have an input box and a button on the web page. The info in the input box becomes the read variable when you click the button. Then it executes the script on the command line and brings back the results on the web page.
The web page is from the same box I wish to execute the grep command -- /var/www/html/index.html. And I have apache installed.
I know the task itself is basically worthless. But the main point is to learn a simple task like this in order to open doors to larger projects.
Its unfortunate that that thread is not, in fact, a joke.
I'm not allowed to post company code,. but I can tell you this. Our user input forms are actually run from different servers, and the input is scrubbed *at least* 10 different ways, and even then it's checked by hardware before it gets truly submitted to the dmz'd input servers.
Last edited by szboardstretcher; 02-26-2014 at 09:27 AM.
Its unfortunate that that thread is not, in fact, a joke.
I'm not allowed to post company code,. but I can tell you this. Our user input forms are actually run from different servers, and the input is scrubbed *at least* 10 different ways, and even then it's checked by hardware before it gets truly submitted to the dmz'd input servers.
Thanks for the info szboardstretcher.
Your solution worked great. Thanks. It was perfect for the novice level I am at with this type of integration and I hope to grow from it. And explaining a little about your system helps me better see the reality of security concerns. I appreciate it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.