LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash in html (https://www.linuxquestions.org/questions/programming-9/bash-in-html-714783/)

aihaike 03-27-2009 04:13 AM

bash in html
 
Dear all,

I have a bash script which looks like that:

Code:

#!/bin/sh

echo Content-type: text/html
echo
echo
echo "<HTML>"
echo "<HEAD>"
echo "</HEAD>"
echo "<BODY>"
echo "<PRE>"
file="/home/www/testcgi.html"
date1=`ls -l $file | cut -d " " -f6`
date2=`ls -l $file | cut -d " " -f7`
date3=`ls -l $file | cut -d " " -f8`
printf "Last updated : $date1 $date2 $date3\n"
echo "</PRE>"
echo "</BODY>"
echo "</HTML>"

I'd like to embed it into an HTML page.
A link like this works:

Code:

<A HREF="http://localhost/cgi-bin/html2.sh">sh</A>
But the following does not:

Code:

<script src="http://localhost/cgi-bin/html2.sh" type="text/javascript"> </script>
I know it's not javascript but this is what I read on the web ...

Any idea?

By the way is it possible to get the file name of an html page in an html script?

Thanks,

Eric.

jlinkels 03-27-2009 06:02 AM

In the first (working) example, the script is called and executed on the server. It produces output which is sent to your browser.

The second example specifies a script which is to be executed on the client, that is inside you web browser. Web browsers do not understand Bash, just Javascript (and I think Visual Basic, maybe some more). A line like this could never work.

jlinkels

aihaike 03-27-2009 06:22 AM

That for your answer I'll try an other way.

Eric.

gnashley 03-27-2009 07:37 AM

You could make your script into a cgi script -it will still be executed on the server machine though.

aihaike 03-27-2009 08:23 AM

This works:

Code:

<object type="text/html" data="http://localhost/cgi-bin/date.py"></object>
Code:

<object type="text/html" data="http://localhost/cgi-bin/html2.sh"></object>
Either with bash or python it works.

Eric.


All times are GMT -5. The time now is 12:41 AM.