Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Stephen Hansen Newsgroups: comp.lang.python Subject: Re: Saving Consol outputs in a python script Date: Tue, 03 May 2016 08:43:59 -0700 Lines: 20 Message-ID: References: <1462290239.1609819.596871457.7356F4C8@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de hvmm9XrKCvMd6lQmDgxRxA26ZKjp04E5lyshbY79d7tA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'method,': 0.07; 'output,': 0.09; 'received:internal': 0.09; 'script,': 0.09; 'subject:script': 0.09; 'output': 0.13; 'subject:python': 0.14; '.py': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'started:': 0.16; 'wrote:': 0.16; 'string': 0.17; "shouldn't": 0.18; 'string,': 0.18; 'variable': 0.18; 'function,': 0.22; 'pipe': 0.22; 'stephen': 0.22; 'file.': 0.22; 'am,': 0.23; 'passing': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'values': 0.28; 'classes': 0.30; 'skip:s 30': 0.31; 'tue,': 0.34; 'could': 0.35; 'text': 0.35; 'saved': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'skip:p 20': 0.38; 'someone': 0.38; 'to:addr:python.org': 0.40; 'header:Message- Id:1': 0.61; 'email addr:gmail.com': 0.62; 'me!': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=aGDbnlcW/pKKJgkWnc7vdY7w3Wk=; b=DPBdWK JiBUQKldLzbvwVOw/bz8eZ8Vi5ZFqi499lFmZJbXRvZ8xFcTJ3YAN8f7/QdkhGRt LSLfropMn1r9HPTkEcq445sA31dsxnSTBpiEU9kjMNWd8ogSVx8ikhH98cQsiaj0 cZxtJm3vC9RMiwaGQ8MKJa+8y6lnrejk9A7f8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=aGDbnlcW/pKKJgk Wnc7vdY7w3Wk=; b=pEotbXtemPPnbtP8wkJ3cwtejPC7UUiPgvTY7zlKzoU2KUj +HLWWKAaigPe6mjOV+XzILKkP7A05DB4n/uRCcW9+AuQTxDYCsU5OjVT6NLtC5FT YPGeu9Z/6NYmomDrIMtSH2t4lz5Lq7PCA5ryw8r5RWBnTJQnUwxO5VNU/pJ0= X-Sasl-Enc: YE4tAGASSdFte4WINiqj/dwrwQAFpgYHyy4wvshvHSNa 1462290239 X-Mailer: MessagingEngine.com Webmail Interface - ajax-103fcf22 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1462290239.1609819.596871457.7356F4C8@webmail.messagingengine.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:108078 On Tue, May 3, 2016, at 05:14 AM, drewes.mil@gmail.com wrote: > What I need are the 2 values for the 2 classes saved in a variable in the > .py script, so that I can write them into a text file. > > Would be super nice if someone could help me! You shouldn't use the call() convienence function, but instead create a process using the Popen constructor, passing PIPE to stdout. Then use communicate() to get the output. This should get you started: process = subprocess.Popen(["commandline"], stdout=subprocess.PIPE) output, error = process.communicate() Output will be a string, string has a splitlines method, etc. -- Stephen Hansen m e @ i x o k a i . i o