RE: OT: How to embed or call a shell script in an html file?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Graham
Date:  
To: Main PLUG discussion list
Subject: RE: OT: How to embed or call a shell script in an html file?
From: joe
> I am more than ever thoroughly persuaded that it will be much better
> for me to pay someone to help me build what I want/need.


Not sure what that is, but people could probably offer some advice on how to
build that (for free, even) if you wrote up a couple of paragraphs of
requirements.

> I have never used one of those website building programs because
> whenever I look at the code generated by them, it always seems to
> me to be a convoluted mess


Feature Creep: It happens in web frameworks too!

> that PHP code example. While I have not yet been able to get it to
> work, I have no doubt that it will work once I understand how to
> implement it.


If your web server is running PHP, all you should need to do is copy all the
stuff from <?php to //end code , then paste it into a file called "search.php"
that resides somewhere under your web server's docroot, then change
/www/stuff.txt to the full pathname to wherever the file you want to grep
through is. Then, going to http://yoursite.example.com/search.php should show
you a simple form with 2 fields and a "Go" button.

If you don't see a form, but the PHP source code, then your webserver doesn't
have PHP enabled. This may be simple to fix, or complicated; it depends on
details.

> Paul then wrote:
>> Web servers only display static assets to clients (browsers), that means
>> if you're using a LAMP set up a PHP vm running in mod-php actually runs
>> the PHP code and then apache serves up the static content to the client.
>> A more common architecture has become nginx -> app server -> database
>> where the app server is frequently php-fpm for php or unicorn for ruby.
> Wow! I have no idea what all that means.


Apache with PHP enabled typically has 2 lines in its config file like so:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php

...load the php5 module, and files ending with .php will be sent to the php5
module, which will execute them. The php scripts will return data (usually
HTML) to apache. apache will then send that data to the browser.

nginx is yet another web server, which is newer and apparently more
fashionable than apache.

> Paul wrote:
>> That being said bash would not be a friendly language choice for
>> writing a web app in and all the major players allow you to shell
>> out to run commands, so you're likely better off letting a more
>> established stack/framework handle some details and shelling out
>> to any bash code you have written.
> I have no idea what "shell out to run commands" and the rest of that
> sentence means.


"shell out" means "start a shell and execute a command, in much the same way
that a shell script does". This is (or at least was) a relatively common
idiom among Unix folks. The rest of it is "use some combination of (apache or
nginx) and (python, perl, PHP, or a framework written in those things) to do
most of your stuff, using the backtick operator or the shell_exec() function
or the system() function to invoke bash scripts from within python/perl/PHP if
you need to."

> examining finished code that is actually working and doing something
> that I want/need to do seems to be the way I learn best; rather than
> trying to read and digest volumes of details about coding techniques,
> rules, and how and why code is supposed to work.


Isn't it that way with *everybody*?

What I usually do is take a small piece of working code that does something
simple (like printing "hello world" 5 times in a for loop) and then add a
little bit to that code. And if it works, keep going. And if it doesn't,
look hard at the errors that show up and fix them. Constantly adding small
bits, and then trying them out to see how they work. After enough iterations,
you'll get something that does something similar to what you want, and you'll
learn a lot about the language you're using.

--
Matt G / Dances With Crows
The Crow202 Blog: http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss