Timeline for How do I execute a program or call a system command?
Current License: CC BY-SA 4.0
46 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 18 at 10:56 | comment | added | Tal Jacob - Sir Jacques |
You can also you split with: subprocess.run("ls -l".split(" "))
|
|
Mar 19 at 13:37 | comment | added | Simao Gomes Viana |
@KevinWheeler Why not just use os.environ and pass it as string?
|
|
Feb 6 at 20:59 | comment | added | Suyash Nande | How can we run a cypress test from this example: "./node_modules/.bin/cypress test1.js" | |
Jan 25 at 8:45 | review | Suggested edits | |||
Jan 25 at 11:36 | |||||
May 19, 2023 at 23:56 | comment | added | user3064538 | @thatrandomperson your comment is useless because you didn't provide an example. no one is able to evaluate what you actually tried, why you expected it to work and explain to you why it didn't work. We just have to take your word that a function used by millions of programs "doesn't work"? | |
May 19, 2023 at 23:52 | history | edited | user3064538 | CC BY-SA 4.0 |
shell=True is unsafe, shorten
|
Mar 20, 2023 at 19:59 | history | edited | Lasse V. Karlsen | CC BY-SA 4.0 |
added 84 characters in body
|
Feb 25, 2023 at 14:20 | history | edited | mirekphd | CC BY-SA 4.0 |
a more scalable `run` syntax (single string, many args) is with `shell=True` + non-trivial example
|
Feb 18, 2023 at 1:15 | history | rollback | sideshowbarker♦ |
Rollback to Revision 18
|
|
Jan 27, 2023 at 23:10 | history | edited | Muhammad Asadullah | CC BY-SA 4.0 |
Added more details with demo codes, tips, security implications, and notes for latest python syntax versions such as 3.5+.
|
May 15, 2022 at 18:55 | comment | added | Sergey Anisimov |
Many arguments version looks like that: subprocess.run(["balcon.exe","-n","Tatyana","-t", "Hello world"])
|
|
Nov 12, 2021 at 16:51 | comment | added | Charlie Parker |
what if I want to pipe things e.g. pip list | grep anatome ?
|
|
Jun 9, 2021 at 18:44 | history | rollback | user3064538 |
Rollback to Revision 16
|
|
May 21, 2021 at 1:30 | history | edited | John Mee | CC BY-SA 4.0 |
Expand the code sample.
|
Feb 10, 2021 at 9:15 | history | edited | user3064538 | CC BY-SA 4.0 |
added 405 characters in body
|
S Nov 15, 2020 at 3:27 | history | suggested | Szymon Bednorz | CC BY-SA 4.0 |
Correct Python code syntax highlighting.
|
Nov 14, 2020 at 23:34 | review | Suggested edits | |||
S Nov 15, 2020 at 3:27 | |||||
Jun 14, 2020 at 8:55 | review | Suggested edits | |||
Jun 14, 2020 at 10:40 | |||||
Aug 31, 2019 at 3:17 | history | edited | Corey Goldberg | CC BY-SA 4.0 |
add version of python needed
|
Aug 22, 2019 at 17:48 | history | edited | martineau | CC BY-SA 4.0 |
Improved formatting.
|
Apr 11, 2019 at 10:15 | review | Suggested edits | |||
Apr 11, 2019 at 10:54 | |||||
Apr 1, 2019 at 22:39 | history | edited | FreshPow | CC BY-SA 4.0 |
added 96 characters in body
|
S Jan 17, 2019 at 16:46 | history | suggested | user3064538 | CC BY-SA 4.0 |
upgrade to Python 3. the official documentation says to use run() instead of call(). Remove duplicate link to the documentation
|
Jan 17, 2019 at 15:19 | review | Suggested edits | |||
S Jan 17, 2019 at 16:46 | |||||
S Oct 15, 2018 at 11:47 | history | suggested | Sani Kamal | CC BY-SA 4.0 |
Remove Python 2 - subprocess link because it will retire 2020
|
Oct 15, 2018 at 10:38 | review | Suggested edits | |||
S Oct 15, 2018 at 11:47 | |||||
Jun 3, 2018 at 14:41 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Active reading.
|
Jul 11, 2017 at 20:54 | review | Suggested edits | |||
Jul 12, 2017 at 4:30 | |||||
Feb 16, 2017 at 12:18 | review | Suggested edits | |||
Feb 16, 2017 at 13:07 | |||||
S Feb 14, 2017 at 13:05 | history | suggested | chobok | CC BY-SA 3.0 |
os.system() does not appear to be currently deprecated, provide different links to python 2/3 docs
|
Feb 14, 2017 at 11:26 | review | Suggested edits | |||
S Feb 14, 2017 at 13:05 | |||||
Dec 13, 2016 at 15:09 | history | edited | Corey Goldberg | CC BY-SA 3.0 |
removed superfluous comment
|
S Nov 13, 2016 at 17:18 | history | edited | Cristian Ciupitu | CC BY-SA 3.0 |
improved formatting
|
Nov 13, 2016 at 16:57 | review | Suggested edits | |||
S Nov 13, 2016 at 17:18 | |||||
Feb 13, 2016 at 14:28 | review | Suggested edits | |||
Feb 13, 2016 at 16:16 | |||||
Nov 11, 2015 at 20:24 | comment | added | Murmel |
@KevinWheeler You should NOT use shell=True , for this purpose Python comes with os.path.expandvars. In your case you can write: os.path.expandvars("$PATH") . @SethMMorton please reconsider your comment -> Why not to use shell=True
|
|
Sep 2, 2015 at 20:38 | comment | added | SethMMorton |
@KevinWheeler You'll have to use shell=True for that to work.
|
|
Sep 1, 2015 at 23:17 | comment | added | Kevin Wheeler |
Is there a way to use variable substitution? IE I tried to do echo $PATH by using call(["echo", "$PATH"]) , but it just echoed the literal string $PATH instead of doing any substitution. I know I could get the PATH environment variable, but I'm wondering if there is an easy way to have the command behave exactly as if I had executed it in bash.
|
|
S Jun 11, 2015 at 6:14 | history | suggested | igauravsehrawat | CC BY-SA 3.0 |
corrected link for python 2 version. Note: python site is updated
|
Jun 11, 2015 at 5:52 | review | Suggested edits | |||
S Jun 11, 2015 at 6:14 | |||||
Jun 27, 2012 at 20:27 | history | edited | ThiefMaster | CC BY-SA 3.0 |
added 55 characters in body
|
Jul 7, 2011 at 14:22 | history | edited | Jim Ferrans | CC BY-SA 3.0 |
edited body
|
S Jun 21, 2011 at 14:15 | history | suggested | Jo Liss | CC BY-SA 3.0 |
link to docs
|
Jun 21, 2011 at 14:10 | review | Suggested edits | |||
S Jun 21, 2011 at 14:15 | |||||
Sep 26, 2008 at 9:06 | vote | accept | freshWoWer | ||
Sep 18, 2008 at 1:39 | history | answered | David Cournapeau | CC BY-SA 2.5 |