Reputation: 617
I'm trying to cronjob my python script. I set it up through cPanel and my python script generates an html file like it's supposed to, so I know the command it correct (just "python /path" right?)
HOWEVER, my generated html stops halfway through (right after the second f.write(), when my for loop should start).
When I execute this script locally, I get no problems, what gives?
from SearchPhone import SearchPhone
phones = ["Iphone 3", "Iphone 4", "Iphone 5","Galaxy s3", "Galaxy s2", "LG Lucid", "LG Esteem", "HTC One S", "Droid 4",
"Droid RAZR MAXX", "HTC EVO", "Galaxy Nexus", "LG Optimus 2", "LG Ignite",
"Galaxy Note", "HTC Amaze", "HTC Rezound", "HTC Vivid", "HTC Rhyme", "Motorola Photon",
"Motorola Milestone", "myTouch slide", "HTC Status", "Droid 3", "HTC Evo 3d", "HTC Wildfire",
"LG Optimus 3d", "HTC ThunderBolt", "Incredible 2", "Kyocera Echo", "Galaxy S 4g",
"HTC Inspire", "LG Optimus 2x", "Samsung Gem", "HTC Evo Shift", "Nexus S", "LG Axis", "Droid 2",
"G2", "Droid x", "Droid Incredible"
]
f = open('celly.html','w')
f.write("""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Celly Blue Book</title>
</head>
<body>
</body>
</html>
""")
#table
f.write('<table width="100%" border="1">')
for x in phones:
y = SearchPhone(x)
f.write( "\t<tr>")
f.write( "\t\t<td>" + str(y[0]) + "</td>")
f.write( "\t\t<td>" + str(y[1]) + "</td>")
f.write( "\t\t<td>" + str(y[2]) + "</td>")
f.write( "\t\t<td>" + str(y[3]) + "</td>")
f.write( "\t\t<td>" + str(y[4]) + "</td>")
f.write( "\t</tr>"
f.write('</table>')
f.close()
Upvotes: 0
Views: 590
Reputation: 43245
Last line in your for loop has syntax error :
f.write( "\t</tr>"
You may not have write permissions on your production server . Try this once.
f = open('/tmp/celly.html','w')
if this works, then its a write permission problem.
Check permissions of your
celly.html
file in current folder. It should be writable.
Upvotes: 1