Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68074 > unrolled thread

Re: process.popen with Japanese args => UTF8 JAVA

Started byCameron Simpson <cs@zip.com.au>
First post2014-03-09 20:09 +1100
Last post2014-03-09 20:09 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: process.popen with Japanese args => UTF8 JAVA Cameron Simpson <cs@zip.com.au> - 2014-03-09 20:09 +1100

#68074 — Re: process.popen with Japanese args => UTF8 JAVA

FromCameron Simpson <cs@zip.com.au>
Date2014-03-09 20:09 +1100
SubjectRe: process.popen with Japanese args => UTF8 JAVA
Message-ID<mailman.7952.1394356176.18130.python-list@python.org>
On 09Mar2014 16:52, Jun Tanaka <tnajun@gmail.com> wrote:
> I have tried to process.popen to run java program with Japanese language.
> test.java is compiled with utf8
> '日本語' below means Japanese in Japanese.
> but it does not work. Anyone who knows this matter well. Please help.
> Jun
> 
> >>>>>>>>python code>>>>>>>>>>>>>
> sentence = '日本語'
> filename = 'japanese'
> java_file = 'test'
> cmd = "java {0} {1} {2}".format(java_file, sentence, filename)
> proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT)
> >>>>>>>>python code end>>>>>>>>>>>>>>>>>>>>>>

Echoing Ben, what errors do you get? And what expected?

But examining your program, it is possible that any error messages
are being concealed. Details below.

Firstly, I am surprised that the sentence comes before the java
file "test". Try swapping them.

Also, if you're doing this in a UNIX system of some kind, and therefore
your "cmd" variable is actually a shell comment, turn on tracing.
Change this:

  cmd = "java {0} {1} {2}"

to this:

  cmd = "set -x; java {0} {1} {2}"

It will show you the command the shell executes.

Finally, why do you have:

  stderr=subprocess.STDOUT

Normally you would leave stderr alone, so that error messages show
on your terminal. In particular, the shell tracing an any error
messages from your java command go to stderr, and grabbing stderr
like that may well be concealing any useful error messages you ought
to be seeing. I would be inclined to simple get rid of your stderr=
parameter and see what shows up.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Processes are like potatoes.    - NCR device driver manual

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web