Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
piping input to an external script
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Tim Arnold, post: 3857657"] Hi, I have some html files that I want to validate by using an external script 'validate'. The html files need a doctype header attached before validation. The files are in utf8 encoding. My code: --------------- import os,sys import codecs,subprocess HEADER = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' filename = 'mytest.html' fd = codecs.open(filename,'rb',encoding='utf8') s = HEADER + fd.read() fd.close() p = subprocess.Popen(['validate'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) validate = p.communicate(unicode(s,encoding='utf8')) print validate --------------- I get lots of lines like this: Error at line 1, character 66:\tillegal character number 0 etc etc. But I can give the command in a terminal 'cat mytest.html | validate' and get reasonable output. My subprocess code must be wrong, but I could use some help to see what the problem is. python2.5.1, freebsd6 thanks, --Tim [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
piping input to an external script
Top