Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old February 6th, 2004, 01:16 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #17  
Old February 6th, 2004, 03:01 PM
rickt's Avatar
rickt rickt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 23 rickt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #18  
Old February 6th, 2004, 04:15 PM
rickt's Avatar
rickt rickt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 23 rickt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by netytan
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.


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

Reply With Quote
  #19  
Old February 6th, 2004, 04:42 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > shutil copyfile: how come it truncates data?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT