Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'kind,': 0.05; 'comment,': 0.09; 'filename': 0.09; 'parameter': 0.09; 'sentence': 0.09; 'received:localdomain': 0.11; 'cc:addr:python-list': 0.11; 'language.': 0.14; 'ben,': 0.16; 'cmd': 0.16; 'filename)': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'inclined': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'ought': 0.16; 'proc': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'stderr': 0.16; 'tracing': 0.16; 'utf8': 0.16; '{0}': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'have:': 0.19; 'normally': 0.19; 'help.': 0.21; 'command': 0.22; 'manual': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'error': 0.23; 'driver': 0.24; 'finally,': 0.24; 'rid': 0.24; 'skip:{ 20': 0.24; 'java': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'compiled': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'leave': 0.29; 'unix': 0.29; 'errors': 0.30; 'work.': 0.31; 'program,': 0.31; 'code': 0.31; 'anyone': 0.31; 'file': 0.32; 'run': 0.32; 'up.': 0.33; 'device': 0.34; 'subject:with': 0.35; 'knows': 0.35; 'but': 0.35; 'received:com.au': 0.36; 'skip:> 10': 0.36; 'doing': 0.36; 'shows': 0.36; 'useful': 0.36; 'possible': 0.36; 'turn': 0.37; 'being': 0.38; 'received:211': 0.38; 'does': 0.39; 'matter': 0.61; 'simple': 0.61; "you're": 0.61; 'content- disposition:inline': 0.62; 'show': 0.63; 'to:addr:gmail.com': 0.65; 'details': 0.65; 'below.': 0.71; 'therefore': 0.72; "'test'": 0.84; 'alone,': 0.84; 'examining': 0.84; 'grabbing': 0.84; 'ncr': 0.84 Date: Sun, 9 Mar 2014 20:09:26 +1100 From: Cameron Simpson To: Jun Tanaka Subject: Re: process.popen with Japanese args => UTF8 JAVA MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=fbeUlSgF c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=kdZtIbajlSkA:10 a=IkcTkHD0fZMA:10 a=vrnE16BAAAAA:8 a=pGLkceISAAAA:8 a=UPWsnKEw1nzx7sICvjwA:9 a=QEXdDO2ut3YA:10 a=MSl-tDqOz04A:10 a=GaQHtnsYC5UA:10 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 52 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394356176 news.xs4all.nl 2938 [2001:888:2000:d::a6]:56693 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68074 On 09Mar2014 16:52, Jun Tanaka 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 Processes are like potatoes. - NCR device driver manual