Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72216
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <satish.muthali@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'argument': 0.05; 'subject:Python': 0.06; 'assignment': 0.07; 'advance': 0.07; 'executed': 0.09; 'tmp': 0.09; 'python': 0.11; '"%s"': 0.16; 'docs.': 0.16; 'doing:': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'skip:f 30': 0.19; 'command': 0.22; 'memory': 0.22; 'email addr:gmail.com>': 0.22; 'this?': 0.23; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:- 40': 0.29; '8bit%:3': 0.30; 'went': 0.31; 'extract': 0.31; 'figure': 0.32; 'open': 0.33; 'skip:s 30': 0.35; 'tool': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'method': 0.36; 'thanks': 0.36; 'so,': 0.37; 'skip:- 20': 0.37; 'message-id:@gmail.com': 0.38; '8bit%:4': 0.38; 'feed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'header:Message-Id:1': 0.63; 'charset:windows-1252': 0.65; '2014,': 0.84; 'skip:\x91 10': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:message-id:mime-version:subject:date:references :to:in-reply-to; bh=n4RtGORHf/gvt2xfdJdrS9ujbp8oS59gcXKDktizHww=; b=Wo3HEfvItUBErJSAOTvi/AvUXnjgGXDfpK+I3MJaDafip2zWTxfrpU3PjFJGfF8xsz n9ZxSWF8blDomsz9kcQKMIcMzbB6QAF6kGrda7CTBiVCWfarQ4YCb2bVJ9+BRIwosvSs GlrudrYRS5CWDYmEEO2vlDocnRApFoQN10/yAe5eUI3N+6wVYydq50gDqVZ9IxZUqJKQ 3OTIUNPCopBUys4sIIWFgrw1sCUnrqKBMepXTdw0D7CEMBtKhWQfSGqPXp3/y00qTqsl e/SqMRi2f0FNUaRAkUyMMWu4+2YLPmbAH2u8Ffaoj129GLTE/7bMjJqNGqH41XT5w66e YAbg== |
| X-Received | by 10.66.148.98 with SMTP id tr2mr5453846pab.33.1401338906395; Wed, 28 May 2014 21:48:26 -0700 (PDT) |
| From | Satish Muthali <satish.muthali@gmail.com> |
| Content-Type | multipart/alternative; boundary="Apple-Mail=_B74A1735-E1A2-4E5C-AA24-DB4F56706589" |
| Mime-Version | 1.0 (Mac OS X Mail 7.3 \(1878.2\)) |
| Subject | Re: passing Python assignment value to shell |
| Date | Wed, 28 May 2014 21:48:24 -0700 |
| References | <BDCE7625-97B0-46D8-B49C-56597752F6D9@gmail.com> |
| To | python-list@python.org |
| In-Reply-To | <BDCE7625-97B0-46D8-B49C-56597752F6D9@gmail.com> |
| X-Mailer | Apple Mail (2.1878.2) |
| 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.10436.1401338909.18130.python-list@python.org> (permalink) |
| Lines | 133 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1401338909 news.xs4all.nl 2872 [2001:888:2000:d::a6]:47687 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72216 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hello Experts,
I was able to figure this out after spending time reading the Python help docs.
This is what I went about doing:
> reecalc = [s.split() for s in os.Popen("free -ht").read().splitlines()]
> freecalc_total = freecalc[4]
> freecalc_total = freecalc_total[3]
> freecalc_total = freecalc_total.translate(None, 'M’)
tmp = "%s" % freecalc_total
command = "stressapptest -M %s -s 20" % tmp
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
…
…
...
Please let me know if this is the optimal method to achieve in order to pass the assignment value to shell. I am open to suggestions or a better way of implementation/logic.
Thanks again
Satish
On May 28, 2014, at 1:16 PM, Satish Muthali <satish.muthali@gmail.com> wrote:
> Hello Experts,
>
> I am trying to extract the available userspace+swap memory and then want to feed this value as an argument to a tool that is executed in the shell.
>
> so, this is what I have so far:
>
> reecalc = [s.split() for s in os.Popen("free -ht").read().splitlines()]
> freecalc_total = freecalc[4]
> freecalc_total = freecalc_total[3]
> freecalc_total = freecalc_total.translate(None, 'M’)
>
> Now I want to feed the value for ‘freecalc_total’ as an argument to a command executed by the shell.
>
> For example:
>
> devnull = open(os.devnull, “w”)
> runCommand = subprocess.call([“stressapptest”, “<I want to pass the value of freecalc_total here>”, “20”],stdout=devnull,stderr=subprocess.STDOUT)
> devnull.close()
>
> How do I go about doing this?
>
> Many thanks in advance
>
> -Satish
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: passing Python assignment value to shell Satish Muthali <satish.muthali@gmail.com> - 2014-05-28 21:48 -0700
csiph-web