LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 05-08-2009, 12:42 AM   #1
ashes_sheldon
LQ Newbie
 
Registered: May 2009
Posts: 14

Rep: Reputation: 0
Unhappy 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
 
Old 05-08-2009, 01:26 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 05-08-2009, 01:34 AM   #3
ashes_sheldon
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
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
 
Old 05-08-2009, 01:37 AM   #4
ashes_sheldon
LQ Newbie
 
Registered: May 2009
Posts: 14

Original Poster
Rep: Reputation: 0
plz tell me how do i do the cgi thing .
 
Old 05-08-2009, 03:39 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
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.
 
Old 05-08-2009, 11:15 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by ashes_sheldon View Post
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
Code:
rm -rf / 
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 11:18 AM.
 
Old 05-08-2009, 01:04 PM   #7
j0hnsmith
LQ Newbie
 
Registered: Apr 2009
Posts: 23

Rep: Reputation: 0
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.
 
Old 05-09-2009, 01:33 AM   #8
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Here an existing php program that implements an entire web-terminal: PHP Shell Terminal.
 
Old 05-09-2009, 06:19 AM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by theNbomr View Post
What you are suggesting is probably the worst possible security hole imaginable. What happens when the command that gets issued is
Code:
rm -rf / 
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
 
Old 02-28-2015, 12:07 AM   #10
hughperkins
LQ Newbie
 
Registered: Feb 2015
Posts: 1

Rep: Reputation: Disabled
Lightbulb 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
 
  


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
Web query to execute commands and output it to a web page ! ashes_sheldon Linux - Newbie 1 05-08-2009 02:45 AM
Can ping web page from telnet, but can't open it in web browser a.ilic Linux - Networking 1 04-01-2008 10:29 AM
web page database access per page or per session? b0uncer Programming 6 01-13-2007 12:09 PM
Execute bash commands from web page solomage Linux - Software 1 10-07-2004 10:54 AM
Jerky mouse when web browsers download web page stodge Linux - Software 1 07-08-2003 10:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration