<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><br>If you turn your shell script into a web app using PHP/MySql then it will run on anything that has a browser. <br><br><br><br>------------------------<br>
Keith Smith<br><br>--- On <b>Sun, 6/23/13, Matt Graham <i><danceswithcrows@usa.net></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Matt Graham <danceswithcrows@usa.net><br>Subject: Re: OT: How to embed or call a shell script in an html file?<br>To: "Main PLUG discussion list" <plug-discuss@lists.phxlinux.org><br>Date: Sunday, June 23, 2013, 11:33 AM<br><br><div class="plainMail">From: joe@<br>> Matt asked:<br>>> How is this working?<br>> Regarding 'readin' , I have a small program by that name<br>> in my /usr/bin (and in ~/www/bin) that enables a hot-key.<br>> Also I have linked 'clear' to 'cls'.<br><br>OK.  You can do this, but doing things like this makes it more difficult for<br>other people to debug your code.<br><br>>>> ... how can I integrate this shell script into an html<br>>>> file as I hope to be able to use
 it in a web page?<br>>> You will have an easier time of it if you use something that's<br>>> designed for creating dynamic web pages, like mod_python or<br>>> CGI-Perl or Ruby on Rails or PHP. <br>> But I don't know how to use any of those<br><br>If you're going to make web pages that do things, you will have to learn<br>something like Ruby/Python/PHP.  Things like wordpress/drupal/django are not<br>written in shell because it's difficult to do the complex stuff that those<br>CMSes require in shell.<br><br>A basic PHP script that should be usable on your web sewer with 1 change:<br><br><?php<br><br>$header='<html><head><title>Test search</title></head><body>';<br>$footer='</body></html>';<br><br>$form='<form action="'.$_SERVER['PHP_SELF'].'" method="get"><br><label>Name 1:</label> <input type="text" name="name1"/><br/><br><label>Name
 2:</label> <input type="text" name="name2"/><br/><br><input type="submit" name="" value="Go"/><br></form>';<br><br>$filename='/www/stuff.txt'; // full path of file you're searching in<br><br>$out='';<br>if(isset($_GET['name1']) and isset($_GET['name2'])){<br>        $o1=htmlentities($_GET['name1']);<br>        $o2=htmlentities($_GET['name2']);<br>        $out.="<p>Searched for: name1 $o1 name2 $o2</p>\n";<br>        $n1=escapeshellarg($_GET['name1']);<br>        $n2=escapeshellarg($_GET['name2']);<br>        $out.="<p>First 10 results:</p>\n<pre>\n";<br>        $out.=`grep -i $n1 $filename | grep -i $n2 | head -n 10`;<br>        $out.="</pre>\n";<br>        }<br><br>print $header;<br>print $out;<br>print
 $form;<br>print $footer;<br>// save as search.php on your PHP-enabled webserver somewhere<br>// end code<br><br>...note that this is very bare-bones and has almost no security attached to<br>it; there are good reasons why real scripts don't just put $_GET vars into<br>shell commands they're executing.  Using `` or system() or shell_exec() is not<br>usually done because there are usually better ways to handle things than<br>shelling out (like a DB and the mysqli or PDO classes).<br><br>It is also easy for beginners to forget to escape data in PHP and make your<br>PHP scripts vulnerable to XSS and SQL injection and all kinds of terrible<br>things.  However, PHP is easy to use for quick one-offs since so much useful<br>stuff is built in to the language.  Hope That Helps,<br><br>-- <br>Matt G / Dances With Crows<br>The Crow202 Blog:  <a href="http://crow202.org/wordpress/" target="_blank">http://crow202.org/wordpress/</a><br>There is no
 Darkness in Eternity/But only Light too dim for us to see<br><br>---------------------------------------------------<br>PLUG-discuss mailing list - <a ymailto="mailto:PLUG-discuss@lists.phxlinux.org" href="/mc/compose?to=PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>To subscribe, unsubscribe, or to change your mail settings:<br><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></div></blockquote></td></tr></table>