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


Groups > comp.lang.python > #82234

Re: Solution to a problem,write terminal output to file

Path csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'configure': 0.05; 'output': 0.05; 'subject:file': 0.07; '(aka': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'suggest': 0.14; 'different,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'programmatic': 0.16; 'stderr': 0.16; 'stdout': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'subject:problem': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'header :In-Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'robert': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'produces': 0.31; 'file': 0.32; 'probably': 0.32; 'run': 0.32; 'linux': 0.33; 'running': 0.33; 'entirely': 0.33; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'machine.': 0.36; 'server': 0.38; 'files': 0.38; 'that,': 0.38; 'sure': 0.39; 'either': 0.39; 'signal': 0.60; 'simply': 0.61; "you're": 0.61; 'press': 0.70; 'subject:,': 0.80; 'subject:Solution': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=SvcaUyHMTp51vG1tSn817DroGa6f4Ftb3Q3punwJS9Y=; b=NvSXjVheCqecn+IcPwxAxN+WYwj2kEXk0Yl3suVVbYC/PLzAuYcCZhT9Da0/LrMf4k 1ZuaDWksEQ/Sbp320bkRjrbP3DvRYpuKVBBGng8ZBz7cCtE62V7z8Qf7eaLr4xulYFOz 9N/wtgrxOTOoF5F4TE9+X+B6qaLAWBpEogBUyHthafGMFAEjT30W7/R1tEv4m/YqSDDr B2B04q6lMt+m/O76Q6crgE7PBxbeu3bFkVi7b/s7mDu7jHIaDUigJp/BtULK8dh1mwTi vYS+2H7kh71ITn7mU9V+z6G7fFg+VlaU0qATtCb9PhArEgGaUOnIWtP3+ykrBa6uVkEY WlHA==
MIME-Version 1.0
X-Received by 10.50.171.168 with SMTP id av8mr4138613igc.2.1418152903240; Tue, 09 Dec 2014 11:21:43 -0800 (PST)
In-Reply-To <CAEMktPWjN0m7m_YFNjcJBJ3xgh46rJXY+5pfQ93fD9xqX88ryw@mail.gmail.com>
References <CAEMktPWjN0m7m_YFNjcJBJ3xgh46rJXY+5pfQ93fD9xqX88ryw@mail.gmail.com>
Date Wed, 10 Dec 2014 06:21:43 +1100
Subject Re: Solution to a problem,write terminal output to file
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16775.1418152906.18130.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418152906 news.xs4all.nl 2923 [2001:888:2000:d::a6]:52246
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82234

Show key headers only | View raw


On Wed, Dec 10, 2014 at 4:11 AM, Robert Clove <cloverobert@gmail.com> wrote:
> I am facing a problem in python coding that is
>
> I have a client server program(programs a re in c code and client and server
> are its executable) on Linux machine.
> To run client i do this ./strace -c client and to run server i type this
> ./strace -c server
>
> When i give ctrl+c to client i see some output on the terminal, i want that
> output in the file i mean i want to send the ctrl+c signal programmatic ally
> to client after a minute and write the output in the file.
>
> if i use subprocess.Popen to execute  ./strace -c client and give ctrl+c
> signal i don''t see any output on the terminal but if i see os.system to
> execute ./strace -c client i see the output on terminal.Now i want to send
> the ctrl+c signal to os.system and write the terminal output into a file.

I'm not entirely sure what you're trying to do here, but strace
produces its output on Standard Error (aka "stderr"). You can simply
redirect that to a file. That's the normal strace program. You might
be running something completely different, since you're running
"./strace"; but I would suggest that it probably uses either stderr or
stdout ("Standard Output"), and you could redirect either or both. Try
this, at the terminal (no Python involved):

./strace -c client >client_out 2>client_err

Then press Ctrl-C, and see which of the files has the output. Based on
that, you could configure subprocess.Popen to send the appropriate
stream to a file.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Solution to a problem,write terminal output to file Chris Angelico <rosuav@gmail.com> - 2014-12-10 06:21 +1100

csiph-web