On 26May2013 13:48, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= <nikos.gr...@gmail.com> wrote: | I'am receiving this now after some tries: | | A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. | | /home/nikos/public_html/cgi-bin/metrites.py in () | 139 else: | 140 sp = subprocess.Popen(['mail', '-f', FROM, '-s', 'Mail from Guest', 'supp...@superhost.gr'], stdin=subprocess.PIPE) | => 141 sp.communicate( MESSAGE ) | 142 status = sp.wait() | 143 if status: | sp = <subprocess.Popen object>, sp.communicate = <bound method Popen.communicate of <subprocess.Popen object>>, MESSAGE = 'kdsjfksdjkfjksdjfs\r\n\t' | /opt/python3/lib/python3.3/subprocess.py in communicate(self=<subprocess.Popen object>, input='kdsjfksdjkfjksdjfs\r\n\t', timeout=None) | 901 if input: | 902 try: | => 903 self.stdin.write(input)
Well, you should probably be writing to sp.stdin, not sys.stdin. | 904 except IOError as e: | 905 if e.errno != errno.EPIPE and e.errno != errno.EINVAL: | self = <subprocess.Popen object>, self.stdin = <_io.BufferedWriter name=5>, self.stdin.write = <built-in method write of _io.BufferedWriter object>, input = 'kdsjfksdjkfjksdjfs\r\n\t' | TypeError: 'str' does not support the buffer interface | args = ("'str' does not support the buffer interface",) | with_traceback = <built-in method with_traceback of TypeError object> This is symptomatic of sys.stdin (well, whatever you're writing to) being open in binary mode instead of text mode. And you're passing a str. Try passing std.encode(). Cheers, -- Cameron Simpson <c...@zip.com.au> Yes, [congress is] petty and venal and selfish. That's why they're called _representatives_. - Will Durst -- http://mail.python.org/mailman/listinfo/python-list