What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » cgi generate a zip file

cgi generate a zip file
Author: Message:
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. cgi generate a zip file
I have some zip generating python saved as a cgi, but the server fails to execute it
quote:
Originally posted by Apache log file
[Thu Apr 23 21:09:21 2009] [error] [client 192.168.1.1] (8)Exec format error: exec of '/Users/alec/Sites/download.cgi' failed
[Thu Apr 23 21:09:21 2009] [error] [client 192.168.1.1] Premature end of script headers: download.cgi

This post was edited on 04-23-2009 at 11:34 AM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














04-23-2009 11:23 AM
Profile E-Mail PM Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
RE: cgi generate a zip file
The code would help :p
04-23-2009 11:31 AM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. RE: cgi generate a zip file
python code:
import zipfile,os
ziped = zipfile.ZipFile('project.zip', 'w')
print "Content-Type: text/html"
print
print """
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head><body><center>"""
x=os.listdir("./")
for item in x:
    if item!="project.zip":
        ziped.write(item)
print "<br>"*5
print"<a href='project.zip'>Click Here to download the source codes</a>"

print"""
</body>
</html>"""

This post was edited on 04-23-2009 at 11:37 AM by Jarrod.

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














04-23-2009 11:36 AM
Profile E-Mail PM Find Quote Report
prashker
Veteran Member
*****


Posts: 5109
Reputation: 104
– / Male / –
Joined: Mar 2005
Status: Away
RE: cgi generate a zip file
Well for one, I see a <center> but no </center>

This post was edited on 04-23-2009 at 11:59 AM by prashker.
04-23-2009 11:59 AM
Profile PM Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. RE: cgi generate a zip file
that won't stop it executing

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














04-23-2009 12:10 PM
Profile E-Mail PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: cgi generate a zip file
quote:
Originally posted by Jarrod
that won't stop it executing
Try adding

code:
#!/usr/local/bin/python


to the first line of your python file (where the path is the path to python)


http://docs.python.org/library/cgi.html#installin...t-on-a-unix-system

This post was edited on 04-23-2009 at 12:54 PM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
04-23-2009 12:53 PM
Profile PM Web Find Quote Report
Jarrod
Veteran Member
*****

Avatar
woot simpson

Posts: 1304
Reputation: 20
– / Male / Flag
Joined: Sep 2006
O.P. RE: cgi generate a zip file
textmate puts that in when I start a new cgi file I just didn't paste it into my post.
textmate does the whole thing correctly as a .py so I'm thinking it's a permissions thing but AFAIK everything is chmod 777

[Image: 5344.png]
[Image: sig.png]

A.k.a. The Glad Falconer














04-23-2009 10:29 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On