|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#16
|
||||
|
||||
|
Ok all done, dont ask me what exacly was wrong with it.
I generally went though and tidied it up; i did remove alot of unwanted file() calls which could have something to do with it. I also changed shutil.copy() to shutil.copyfile() but i dout that was the problem. Code:
import urllib, httplib, filecmp, os, shutil
params = urllib.urlencode({'R':'yes','D':'MH'})
h = httplib.HTTP('securityresponse.symantec.com:80')
h.putrequest('POST', '/avcenter/cgi-bin/updates_msa.cgi')
h.putheader('Content-length', '%d' % len(params))
h.putheader('Accept', 'text/plain')
h.putheader('Host', 'securityresponse.symantec.com')
h.endheaders()
h.send(params)
reply, msg, hdrs = h.getreply()
print reply
data = h.getfile().read()
file('NIDS.html','w').write(data)
print 'Grabbed the HTML and wrote the file.'
match = filecmp.cmp('NIDS.html', 'NIDS_Original.html')
if match == False:
shutil.copyfile('NIDS.html', 'c:\\documents and settings\\all users\\desktop\\ALERT Symantec Page Changed.html')
shutil.copyfile('NIDS.html', 'NIDS_Original.html')
print 'FALSE: Copied NIDS.html to ALERT on the desktop.'
else:
print 'TRUE: Deleted the temp file NIDS.html.'
os.remove('NIDS.html')
Anyway test it out and let me know if it works for you .Mark. |
|
#17
|
||||
|
||||
|
The page I'm trying to recieve is the Symantec Security Updates page. But before that page will load you have to submit yes to a cgi form. I've grabed the actual POST data of a network capture and found that what is actually submitted to the cgi script is:
D=MH&R=yes Which I think is something like device=manhunt and return=yes. The cgi is actually looking to make sure that you have a support contract and forces you to answer yes to get to the updates page. To start off with I have a file called HIDS.html in the directory that I keep that app in which is a copy of the file returned once you submit the data to the cgi script. The python app runs and then compares the results to the old HIDS.html file. -Rick |
|
#18
|
||||
|
||||
|
Quote:
Thanks Mark, that works. I've been going over it and comparing the differences between it and my code. Thanks. I have another script to write that performs the same type of function... hopefully I can get that one done myself. Thanks again! -Rick |
|
#19
|
||||
|
||||
|
No problem Rick, if not then give us a post. Anyway you should luck into sending data by get. Most CGI scripts dont care which method you use and GET is alot easier to use.
Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > shutil copyfile: how come it truncates data? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|