LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-27-2009, 04:13 AM   #1
aihaike
Member
 
Registered: Feb 2006
Location: Paris, France
Distribution: Slackware, CentOS
Posts: 270

Rep: Reputation: 20
Question 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.
 
Old 03-27-2009, 06:02 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
 
Old 03-27-2009, 06:22 AM   #3
aihaike
Member
 
Registered: Feb 2006
Location: Paris, France
Distribution: Slackware, CentOS
Posts: 270

Original Poster
Rep: Reputation: 20
That for your answer I'll try an other way.

Eric.
 
Old 03-27-2009, 07:37 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You could make your script into a cgi script -it will still be executed on the server machine though.
 
Old 03-27-2009, 08:23 AM   #5
aihaike
Member
 
Registered: Feb 2006
Location: Paris, France
Distribution: Slackware, CentOS
Posts: 270

Original Poster
Rep: Reputation: 20
Thumbs up

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.
 
  


Reply



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
bash scripting for html generation daveoily Linux - Newbie 37 08-12-2008 12:16 AM
html/php frontend for bash rookiepaul Linux - General 5 03-05-2006 03:20 PM
ls *.html bash scripting bhar0761 Linux - Newbie 15 09-20-2005 11:07 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
How can I transform XML into HTML on bash? pedrosan Linux - Newbie 0 04-22-2004 02:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:28 AM.

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
Open Source Consulting | Domain Registration