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

joe at actionline.com joe at actionline.com
Sun Jun 23 09:14:59 MST 2013


Matt asked:
> How is this working? If I paste the above into temp.sh and
> execute it, it says "/bin/bash: - : invalid option". If I fix
> the interpreter line so it says "#!/bin/bash" , it complains
> that readin and cls are not valid bash commands. If I replace
> "ans=`readin`" with "read ans" and "cls" with "clear",
> it fails with a syntax error because "esac done" is in there twice.

You're right, "esac done" should not be there twice.
Regarding 'readin' , I have a small program by that name
in my /usr/bin (and in ~/www/bin) that enables a hot-key.
Also I have linked 'clear' to 'cls'.


So, back to my original question:
>> ... how can I integrate this shell script into an html
>> file as I hope to be able to use it in a web page?

Matt replied:
> This is *not* a good idea.  Creating dynamic web pages with
> shell can be done, but it's not one of the things that shell
> is designed for/good at. One way is briefly described at
> http://httpd.apache.org/docs/2.2/howto/ssi.html

Thanks, I'll investigate that.

> You will have an easier time of it if you use something that's
> designed for creating dynamic web pages, like mod_python or
> CGI-Perl or Ruby on Rails or PHP.

But I don't know how to use any of those (and very little else ;)
but at least this shell script has worked well (and very fast)
for me for many years.  I don't know how to do anything else.


>> #!/bin/bash - This shell script that I have named "qsearch" now works.
>>
>> while (:) do
>> echo -e "Press S to search >>> \c"; ans=`readin`; echo; case $ans in
>>   [sS]) echo -e "Find what word? \c";read name1
>>         echo -e "and what second word? \c";read name2
>>         fgrep -y "$name1" q-hid | fgrep -y "$name2" > tempz
>>         cls; echo -e "\nSearch word(s): $name1 $name2";
>>         echo "Here are the first 10 results found:"; echo
>>         head -10 tempz; echo;;
>>   [qQ]) cls; echo; exit;;
>>   *) cls; echo "Not a valid option."; echo;; esac done

I added this (below) in my post because I didn't notice that
it was already there.

>> esac
>> done





More information about the PLUG-discuss mailing list