05-15-2007
Python, HTML, and Unix
Hi Experts,
This may be the wrong category for posting my question, or it could be the perfect category to post. I have no idea how difficult my problem is.
I have python 2.3 installed in my server machine. I am trying to create a web page with python script in it. Now this can be a .html page with python embedded in it, or it could be a .py page with html embedded in it. Whatever it is, it's okay. I cannot use python templates like Kid, Spyce, etc., because my System Admin will not install new software into the machine (it's a 64 bit, cluster server, and he is very possessive about it). I have the CentOS operating system (a version of Red Hat Linux Enterprise). I followed the simple instructions given online, and created a page called trial.py with the following code in it:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World!!! <br />"
print "this is on the next line because of the line break above"
saved it into the public_html folder, and did $chmod 777 trial.py. Now, when I access this page from the browser (firefox) I get the display on the page to be the exact same code that I had written. That is, the page shows me:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World!!! <br />"
print "this is on the next line because of the line break above"
Now, the path to python, is /usr/bin/python. I have verified this with $which python, and I also have some python programs running with crontab that use this path, /usr/bin/python. I changed the file name to trial.cgi, did $chmod 777 trial.cgi, and use firefox to go to it, and I get a 403 Forbidden message saying "You don't have permission to access /~davidfrank/trial.cgi on this server".
So, I tried the other way around. I created a page called new.html, and once again followed the instructions in another online place and wrote the code as:
<html>
<body>
<script language="python2.3">
<!--
print "hello world!"
import string, re
-->
</script>
</body>
</html>
I again saved this into the public_html folder and did $chmod 777 new.html. Now when I access this page from the web browser (firefox), I get nothing on the display. The page is blank.
Please please do help me out. What am I doing wrong?! Is there a tutorial on this. Once again, I cannot use a framework like Kid or Spyce. I have to use the coding that is similar to other scripting languages.
I do not know if the server has Apache or CGI. I am guessing that my server uses Apache since several of the associated web addresses that have the same owners and name servers do use apache. So, now I create this .htaccess file (chmod 777) with the content as:
Options +ExecCGI
AddHandler cgi-script .py
and store it in the public_html folder (this has all the web page files for my username), but no effect. So, I try out the following content:
Options +ExecCGI
AddHandler cgi-script cgi pl
but still no effect. Then finally, I try out:
Options +ExecCGI
AddHandler cgi-script
and no effect after that too. I am at a complete loss now. If someone could please tell me what I am doing wrong or what I should do to get this working, I would truly appreciate it!
Thank you for your time and effort.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
AAAHHH!! I've made a perl program that you can run on a web browser. This program needs to be run everyday, and I don't want to have to run it everyday. The problem is when I try running the program from my terminal, all it does is print stuff to the terminal page (the program involves a lot of... (4 Replies)
Discussion started by: sstevens
4 Replies
2. Programming
Hi,
I'm trying to wrap my head around piping in C - I've got a small C program that forks and pipes stuff from the child process to the parent process.
Currently the child process calls a C program that squirts out random numbers which then pipes the result to the parent process.
The... (0 Replies)
Discussion started by: Dreams in Blue
0 Replies
3. Shell Programming and Scripting
Hi,
I am going to handle a project that uses Python on AIX or SunSolaris Plateform. Please tell me what is Python and how and why we should use Python.
Please suggest.
Thanx. (2 Replies)
Discussion started by: sanjay1979
2 Replies
4. Web Development
I want to create a login page in HTML which is hosted on apache server.
The login page first authenticate the user and then directed to a form which in turn run a script on the server.
I want to make login page without php or jsp.
Please advice. (13 Replies)
Discussion started by: ravi18s
13 Replies
5. UNIX for Advanced & Expert Users
hi all,
I had raised the same question a few weeks back but forgot to mention a lot of points ... so i am raising a new thread furnishing my requirement ... sorry for that ....
here is my problem.
i have a html that look like below
<tr class="modifications-oddrow">
<td... (2 Replies)
Discussion started by: sais
2 Replies
6. UNIX for Advanced & Expert Users
Dear,
I have a requirement as below:
I need an exe or bat file to facilitate multiple end users to upload their files (csv or xls) from windows environment to Unix server.
Any front end like html would also be fine, I can develop a simple HTML script with browse button but not sure on... (4 Replies)
Discussion started by: Imran_Chennai
4 Replies
7. Shell Programming and Scripting
Hi i need to send mail from my Unix server i used the below code.
From: TTS.OO.Monitoring.Operations
Subject: Error
X-Mailer: htmlmail 1.0
Mime-Version: 1.0
Content-Type: text/html; charset=US-ASCII
<HTML><head><style type='text/css'>
table.altrowstable { font-family:... (6 Replies)
Discussion started by: mohanalakshmi
6 Replies
8. UNIX for Advanced & Expert Users
I am planning to run an automation , Could anyone try to help me to how to write an html in unix scripting so when I try to send email it should work especially with Bold and colors (6 Replies)
Discussion started by: cassia
6 Replies
9. Shell Programming and Scripting
Hi
i have below code which i am running and the out i want should be in red color
echo "<html>" >> ERROR_FILE.html
echo "<Body>" >> ERROR_FILE.html
nawk 'BEGIN{print "<table border="1">"}
{print "<tr>";
print "<TD colspan="0" bgcolor="#DC143C">";
for(i=1;i<NF;i++)... (5 Replies)
Discussion started by: mirwasim
5 Replies
10. Shell Programming and Scripting
so, the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter...i.e. #!/bin/perl, or #!/bin/python. so in the case of a perl script, for instance, a perl script cannot and will never run if the perl program is not installed/present on the system. ... (9 Replies)
Discussion started by: SkySmart
9 Replies
PYDOC(1) BSD General Commands Manual PYDOC(1)
NAME
pydoc -- the Python documentation tool
SYNOPSIS
pydoc name
pydoc -k keyword
pydoc -p port
pydoc -g
pydoc -w module ...
pydoc --help
DESCRIPTION
pydoc shows text documentation on something related to python(1). The name argument may be the name of a Python keyword, topic, function,
module, or package, or a dotted reference to a class or function within a module or module in a package. If name contains a '/', it is used
as the path to a Python source file to document. If name is 'keywords', 'topics', or 'modules', a listing of these things is displayed.
OPTIONS
-k keyword Search for a keyword in the synopsis lines of all available modules.
-p port Start an HTTP server on the given port on the local machine.
-g Pop up a graphical interface for finding and serving documentation.
-w module ... Write out the HTML documentation for a module to a file in the current directory. If module contains a '/', it is treated as
a filename; if it names a directory, documentation is written for all the contents.
--help Prints out a help message.
AUTHOR
Moshe Zadka, based on "pydoc --help"
SEE ALSO
python(1)
Dec 19, 2003