LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-11-2010, 03:25 PM   #1
ixcel87
LQ Newbie
 
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19

Rep: Reputation: 0
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!
 
Old 05-11-2010, 03:45 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
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.
 
Old 05-11-2010, 04:53 PM   #3
ixcel87
LQ Newbie
 
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19

Original Poster
Rep: Reputation: 0
So Javascript won't work?

I see that you mentioned a 'web server', must I set up an Apache server?
 
Old 05-11-2010, 05:02 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
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.
 
Old 05-11-2010, 05:22 PM   #5
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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 05:26 PM.
 
Old 05-11-2010, 05:26 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ixcel87 View Post
...
I would like to know where I should begin.
...
Well, you should begin (if you haven't yet) from understanding:
  1. what creates WEB pages;
  2. what displays WEB pages;
  3. how the entity that displays WEB pages passes back to the entity that creates WEB pages user input;
  4. which of the two entities is the originator from human user point of view.

The originator in the same terms as WRT phone conversation.
 
Old 05-12-2010, 11:35 AM   #7
ixcel87
LQ Newbie
 
Registered: Feb 2006
Location: Brooklyn, NY
Distribution: Ubuntu 11.10
Posts: 19

Original Poster
Rep: Reputation: 0
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.
 
Old 05-12-2010, 11:45 AM   #8
HasC
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: Reputation: 55
Quote:
Originally Posted by ixcel87 View Post
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
 
Old 05-12-2010, 04:22 PM   #9
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ixcel87 View Post
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.
 
  


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
Invoking shell scripts from Different Nodes !! balakrishnay Linux - General 1 12-28-2009 12:58 AM
Invoking remote commands from ssh hamtavs Linux - Software 5 06-27-2009 09:03 AM
Invoking a programme on a remote machine, bypassing the unix authentication process.` sk_brahma2008 Linux - Newbie 4 07-01-2008 07:18 AM
Invoking a shell script remotely. niks27 Linux - Newbie 1 10-11-2007 08:22 AM
Shell commands in HTML? Spooky Programming 8 01-01-2004 12:18 PM


All times are GMT -5. The time now is 11:39 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration