It IS simple! (or should be.) - What exactly are you doing?
And what exactly isn't working? ( and do you have the right
options turned on on your server, and is you script in a
directory where the server can access + execute it ? )
This is not linked into anywhere from our home page -
this was just my first try at a python cgi script.
You can look at the output by connecting to URL:
Not a particularly neat or orderly program - I was trying to
see if I understood the protocol ( and after 3 or 4 tries, I
think I finally do! ;-)
This SHOULD give (my) local-time,
( This is where I ran into the tzset() problem, although I do
believe that time should be available from a CGI environment
cal output with today's data in <B>old<\B> and a fortune cookie
message. ( And it does do all that on *my* Mosaic/X11, at least. )
- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics
if time.timezone == 0 :
time.TIME = time.time() - 14400.0 # TZ bug kludge
else: time.TIME = time.time()
day = repr(time.localtime( time.TIME ))
calout = posix.popen( 'cal', 'r' ).readlines()
mon=string.strip( calout )
print 'Content-type: text/html\n'
print '<TITLE>"Calendar:' +mon+ '" </TITLE>'
print '<H2>', date, '</H2>'
for line in calout[2:] :
i = string.find( line, day )
if i <= 0 :
print line[:i] + '<B>' + line[i:i+len(day)] + '</B>' + line[i+len(day):]
if 'DEBUG' in sys.argv[1:] :
if posix.environ.has_key('TZ') and posix.environ['TZ']:
else: print 'NO TZ'
for line in posix.popen( '/usr/games/fortune' , 'r' ).readlines():