Linux - NewbieThis 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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I do know what they do, but what I´m trying to do here is to make them work in the browser by calling the script, but all that I can achieve is that the browser actually opens the script but only prints the commands not what they are supposed to do, for example the hostname displays "wasa" in the terminal, but when I run the script in the browser it prints "hostname".
The web server probably doesn't know how to run Bash scripts. I don't know if it's possible to do that with Apache, either. What you'll probably need to do is use something the server can deal with (e.g. PHP - see mod_php, I believe) to either run your script and provide the output, or to replace your script (if PHP, say, has functionality to replicate what you're doing with Bash).
Hmm, perhaps I misunderstood what you want to do. Browsers don't execute Bash scripts, either.
Very true, but you were close when you mentioned PHP and the Apache Server.
You can use PHP to make system calls (system()) which would execute a bash script, you just have to designate variables to capture the output. Then you can have the web server dynamically construct the page and serve it.
It's a great beginners PHP project if anybody is interested in learning PHP/Apache administration
The web server probably doesn't know how to run Bash scripts.
That indeed is not listed in a stock httpd configuration.
Originally Posted by ndc85430
I don't know if it's possible to do that with Apache, either.
Yes, Apache can (just configure it to accept BASH scripts as valid CGI) but obviously there's languages that are traditionally or commonly used as CGI.
Originally Posted by WasaProduction
(..) what I´m trying to do here is to make them work in the browser by calling the script (..)
If there's no specific reason for using a browser (you haven't told us about BTW) then why not use SSH instead? As in 'ssh user@system some commands;'? (Also note that if your question is part of Something Completely Different you may run into commands that require more privileges than the user the web server runs as is allowed. If and once you've reached that stage please consider very carefully security-wise which replies you accept as as valid answer. The Devil's in the details, there's often multiple approaches and solutions, so please be clear and detailed in what you ask for.)
What im trying to acomplish here is something that a professor said that could be done, there is no point in using a browser, only finding if it is possible, and yes it is very insecure, everything im creating has all the permissions that i could give it and everyone can access them (fortunately im in a virtual machine). but it think that as it is shown in the page
there is a way and maybe there are not 100% bash commands and it have some HTML but if I can achive it lets go for it, but im new in this so i dont fully understand what they are doing there in order to apply it myself.
Last edited by WasaProduction; 05-18-2014 at 03:19 PM.
The link you posted is related to what unSpawn posted above about CGI. It looks like the scripts there are generating the response - some HTML with the contents of a file in it. The stuff between "/bin/cat << EOM" and "EOM" at the bottom of the script is known as a here document.