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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-11-2010, 02:25 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19
Rep:
|
Invoking UNIX shell commands from HTML webpage
Hello all,
I have a few questions regarding HTML, UNIX and Javascript. I've been tasked with creating a fairly simple webpage that takes a few inputs. Each input must correspond to an argument in a UNIX command running on a server.
Here's the background. On a UNIX server we have a script (.ksh) that takes 3 arguments. The result of the script is a data file which is FTP'ed to an external server. Let's forget about the FTP portion for now. I would like to know where I should begin.
What I know so far:
1) I will need HTML to create the webpage. Skill level is high
2) I will need Javascript to make my webpage more interactive. Skill level is high.
3) I will need to understand the UNIX environment. Skill level is high.
What else will I need to complete this task?
Thanks in advance!
|
|
|
|
05-11-2010, 02:45 PM
|
#2
|
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,474
|
You'll need to unsderstand the glue between the "HTML" page and the Unix environment and how to set up your Web server to execute the script. I say "HTML" because straight HTML can't do this. You'll need a script written in Perl, PHP, Python, Ruby, ... to call the Unix commands. These scripting languages can make generating the HTML require less typing, too.
You'll also need to understand security, input validation, and the like. Having a web-accessible page call Unix commands should be setting off alarm klaxons in your head.
|
|
|
|
05-11-2010, 03:53 PM
|
#3
|
|
LQ Newbie
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19
Original Poster
Rep:
|
So Javascript won't work?
I see that you mentioned a 'web server', must I set up an Apache server?
|
|
|
|
05-11-2010, 04:02 PM
|
#4
|
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,474
|
I don't think JavaScript can call external programs, no, but I don't use it much.
You don't have to use Apache.. you can use Lighttpd, nginx, IIS.. whatever Web server you want. But you generally need a Web server to serve up Web pages.
|
|
|
|
05-11-2010, 04:22 PM
|
#5
|
|
Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,861
Rep: 
|
Quote:
|
I've been tasked with creating a fairly simple webpage that takes a few inputs. Each input must correspond to an argument in a UNIX command running on a server.
|
The answer is "CGI".
Perl and PHP are two great choices.
Scan through this tutorial (or Google for any of a million others):
http://www.lies.com/begperl/
Quote:
|
On a UNIX server we have a script (.ksh) that takes 3 arguments. The result of the script is a data file which is FTP'ed to an external server. Let's forget about the FTP portion for now.
|
Again, the answer is "CGI". For example, in Perl and PHP you could use the "system()" function to execute your script:
http://www.perlmonks.org/?node_id=78523
WARNING:
Executing *any* user commands on the server is a *huge* potential security risk. No matter *how* you do it. Be careful!
Here's another good link:
http://perldoc.perl.org/perlsec.html
Last edited by paulsm4; 05-11-2010 at 04:26 PM.
|
|
|
|
05-11-2010, 04:26 PM
|
#6
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by ixcel87
...
I would like to know where I should begin.
...
|
Well, you should begin (if you haven't yet) from understanding:
- what creates WEB pages;
- what displays WEB pages;
- how the entity that displays WEB pages passes back to the entity that creates WEB pages user input;
- which of the two entities is the originator from human user point of view.
The originator in the same terms as WRT phone conversation.
|
|
|
|
05-12-2010, 10:35 AM
|
#7
|
|
LQ Newbie
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19
Original Poster
Rep:
|
Thanks guys!
The websites you guys provided are all very helpful. I will try the following:
1) upgrade my ubuntu machine
2) install apache 2.2 on ubuntu
3) create simple webpage
4) create a simple unix script (to be invoked by the webpage)
5) read up on PHP and Perl (not sure with one i will use)
can someone please touch upon the security aspect of this implementation?
from a security perspective, all of my development will be localized to my unix server. all webpages, scripts, etc... will be created and run from one machine; and i will be the only person with access. Of course when i look to implement a bigger solution i will have to think about the security risks.
|
|
|
|
05-12-2010, 10:45 AM
|
#8
|
|
Member
Registered: Oct 2009
Location: South America - Paraguay
Distribution: Debian 5 - Slackware 13.1 - Arch - Some others linuxes/*BSDs through KVM and Xen
Posts: 329
Rep:
|
Quote:
Originally Posted by ixcel87
So Javascript won't work?
I see that you mentioned a 'web server', must I set up an Apache server?
|
JavaScript won't do, because it's _client-side_ scripting
What the OP needs is _server-side_ scripting: PHP, Perl, Ruby, and the like
|
|
|
|
05-12-2010, 03:22 PM
|
#9
|
|
Senior Member
Registered: May 2005
Posts: 4,397
|
Quote:
Originally Posted by ixcel87
Thanks guys!
The websites you guys provided are all very helpful. I will try the following:
1) upgrade my ubuntu machine
2) install apache 2.2 on ubuntu
3) create simple webpage
4) create a simple unix script (to be invoked by the webpage)
5) read up on PHP and Perl (not sure with one i will use)
can someone please touch upon the security aspect of this implementation?
from a security perspective, all of my development will be localized to my unix server. all webpages, scripts, etc... will be created and run from one machine; and i will be the only person with access. Of course when i look to implement a bigger solution i will have to think about the security risks.
|
The item in red is not quite precisely formulated. Because of the page the user sees he/she will enter some data and/or click on something, and those actions will produce a request to server to do something, e.g. to run a script with the data provided by user.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:15 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
|
|