Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
05-08-2009, 01:42 AM
|
#1
|
LQ Newbie
Registered: May 2009
Posts: 14
Rep:
|
executing linux commands from web page and outputing it back to the web page
hi fellas
I wanted to know if i can execute commands on linux console through a web page and redirect it back to my web page !
For example :
if i send a query "ls"
it should execute this command on my linux console and also redirect the list of the files to the web page from which i give the command !
please help me out ..
regards,
ashes_sheldon
|
|
|
05-08-2009, 02:26 AM
|
#2
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
You can use cgi script to have the output written to the web page, but I don't think you can easily make it output to the console -the webpage has no way of knowing which console or terminal you are on.
|
|
|
05-08-2009, 02:34 AM
|
#3
|
LQ Newbie
Registered: May 2009
Posts: 14
Original Poster
Rep:
|
thnks ..
but does the cgi script queries execute commands given from web page in console ?
i can easily redirect the console o/p by
command >> test.html
but how do i format my contents .. the display is in single line 
|
|
|
05-08-2009, 02:37 AM
|
#4
|
LQ Newbie
Registered: May 2009
Posts: 14
Original Poster
Rep:
|
plz tell me how do i do the cgi thing .
|
|
|
05-08-2009, 04:39 AM
|
#5
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
Here's a small example which shows the output of two commands and refreshes itself.
Code:
#!/bin/bash --
echo -en "Content-type: text/html\n\n<META HTTP-EQUIV="REFRESH" CONTENT="10\;URL=http://localhost/httpd/html/bash-cgi/combo.cgi">\n"
echo "<html><head><title>OS Version</title></head><body><H1>"; /usr/bin/uname -r
echo "</H1>"
echo "<hl>"
echo "<H2>"; /usr/bin/date
echo "</H2>"
echo "</body></html>"
It's important to note that the commands will be executed by the httpd server you are running, so they will run with the same username and group as the server itself. You have to be careful about what commands you let be run...
You can use it by placing it in your cgi-bin dir and making it executable, or you can change the name of it and open it directly in your browser.
|
|
|
05-08-2009, 12:15 PM
|
#6
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
|
Quote:
Originally Posted by ashes_sheldon
hi fellas
I wanted to know if i can execute commands on linux console through a web page and redirect it back to my web page !
For example :
if i send a query "ls"
it should execute this command on my linux console and also redirect the list of the files to the web page from which i give the command !
please help me out ..
regards,
ashes_sheldon
|
What you are suggesting is probably the worst possible security hole imaginable. What happens when the command that gets issued is
There is probably a list of blackhats trying to figure out how to access your server right now.
--- rod.
Last edited by theNbomr; 05-08-2009 at 12:18 PM.
|
|
|
05-08-2009, 02:04 PM
|
#7
|
LQ Newbie
Registered: Apr 2009
Posts: 23
Rep:
|
If you want to run a specific command to output to the page each time it's called you can use SSI, see http://httpd.apache.org/docs/1.3/how...cutingcommands
This doesn't let the user of the page choose the command to enter.
|
|
|
05-09-2009, 02:33 AM
|
#8
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep: 
|
Here an existing php program that implements an entire web-terminal: PHP Shell Terminal.
|
|
|
05-09-2009, 07:19 AM
|
#9
|
Senior Member
Registered: May 2005
Posts: 4,481
|
Quote:
Originally Posted by theNbomr
What you are suggesting is probably the worst possible security hole imaginable. What happens when the command that gets issued is
There is probably a list of blackhats trying to figure out how to access your server right now.
--- rod.
|
http://en.wikipedia.org/wiki/Chroot
|
|
|
02-28-2015, 01:07 AM
|
#10
|
LQ Newbie
Registered: Feb 2015
Posts: 1
Rep: 
|
securewebcmd
Hi,
You can use github.com/hughperkins/securewebcmd
- encrypted, using https
- password protected, using md5 hash
- used nodejs: simple to install and run, dont need apache etc
- can provide a whitelist of allowed commands
- built using nodejs, bootstrap, jquery, express, and angular
- opensource, MPL
|
|
|
All times are GMT -5. The time now is 02:51 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|