Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72191 > unrolled thread
| Started by | Satish Muthali <satish.muthali@gmail.com> |
|---|---|
| First post | 2014-05-28 13:16 -0700 |
| Last post | 2014-05-28 21:40 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
passing Python assignment value to shell Satish Muthali <satish.muthali@gmail.com> - 2014-05-28 13:16 -0700
Re: passing Python assignment value to shell John Gordon <gordon@panix.com> - 2014-05-28 21:40 +0000
| From | Satish Muthali <satish.muthali@gmail.com> |
|---|---|
| Date | 2014-05-28 13:16 -0700 |
| Subject | passing Python assignment value to shell |
| Message-ID | <mailman.10422.1401310723.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2014-05-28 21:40 +0000 |
| Message-ID | <lm5l3u$djm$1@reader1.panix.com> |
| In reply to | #72191 |
In <mailman.10422.1401310723.18130.python-list@python.org> Satish Muthali <satish.muthali@gmail.com> writes:
> 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>'], stdout=devnull,stderr=subprocess.STDOUT)
> devnull.close()
I think you can just include freecalc_total directly as part of the
argument list, like this:
runCommand = subprocess.call(['stressapptest', freecalc_total],
stdout=devnull, stderr=subprocess.STDOUT)
--
John Gordon Imagine what it must be like for a real medical doctor to
gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web