# \#cmd

**URL:** https://discourse.julialang.org/tag/cmd/457.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Running commands in sequence in a pipeline](https://discourse.julialang.org/t/running-commands-in-sequence-in-a-pipeline/51374)

<div class="topic-metadata">

**Author:** [@nstgc](https://discourse.julialang.org/u/nstgc)\
**Replies:** 15\
**Last updated:** [November 25, 2025, 12:47pm UTC](https://discourse.julialang.org/t/running-commands-in-sequence-in-a-pipeline/51374 "2025-11-25T12:47:17Z")

</div>

I am writing a script which—at least in BASH—best works with subshells. The basic structure is “(do something; do something else; etc.) | the next thing|…”. A minimal working example (in BASH) would be: (echo -n "Hello …

---

## [Interpolate into an AppleScript called through Cmd](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824)

<div class="topic-metadata">

**Author:** [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Replies:** 1\
**Last updated:** [December 13, 2024, 8:57pm UTC](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824 "2024-12-13T20:57:08Z")

</div>

The background: the NativeFileDialog.jl unfortunately makes problems on MacOS 15 (i.e. current version). I’m trying to put together a workaround. This one actually works: cmd1 = \`osascript -e 'POSIX path of (choose fi…

---

## [Shell Command to make environmental variables](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997)

<div class="topic-metadata">

**Author:** [@s-baumann](https://discourse.julialang.org/u/s-baumann)\
**Replies:** 2\
**Last updated:** [July 13, 2024, 1:20pm UTC](https://discourse.julialang.org/t/shell-command-to-make-environmental-variables/116997 "2024-07-13T13:20:19Z")

</div>

I am on linux and trying to execute the following in a Julia REPL: run(export JULIA\_NUM\_THREADS=4) I get the error ERROR: IOError: could not spawn export JULIA\_NUM\_THREADS=4: no such file or directory (ENOENT) I can…

---

## [Reading/writing to stdio of running process/command does not work - reading blocks or is empty](https://discourse.julialang.org/t/reading-writing-to-stdio-of-running-process-command-does-not-work-reading-blocks-or-is-empty/113262)

<div class="topic-metadata">

**Author:** [@efficiencynuts](https://discourse.julialang.org/u/efficiencynuts)\
**Replies:** 6\
**Last updated:** [April 21, 2024, 7:42am UTC](https://discourse.julialang.org/t/reading-writing-to-stdio-of-running-process-command-does-not-work-reading-blocks-or-is-empty/113262 "2024-04-21T07:42:07Z")

</div>

Opening a prolog shell/repl process and sending strings to stdin and reading output doesn’t work. I don’t know what I am doing wrong but I tried a few methods and none of them seem to succeed. I just wanna run a long run…

---

## [Quoting when constructing commands problematic?](https://discourse.julialang.org/t/quoting-when-constructing-commands-problematic/109023)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 6\
**Last updated:** [January 19, 2024, 8:41pm UTC](https://discourse.julialang.org/t/quoting-when-constructing-commands-problematic/109023 "2024-01-19T20:41:30Z")

</div>

I think the construction of commands objects on Windows uses improper quoting for directories. See PlotlyJS causes errors, can't figure out how to use PlotlyLight - how to use Plotly from Julia? - #27 by PetrKryslUCSD

---

## [Error with setting TZ=UTC when running touch in Julia](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315)

<div class="topic-metadata">

**Author:** [@KeepLearning](https://discourse.julialang.org/u/KeepLearning)\
**Replies:** 2\
**Last updated:** [December 11, 2023, 2:32am UTC](https://discourse.julialang.org/t/error-with-setting-tz-utc-when-running-touch-in-julia/107315 "2023-12-11T02:32:47Z")

</div>

Hi, I wanted to run the unix command in Julia as follows: run(\`TZ=UTC touch -t "YYMMDDhhmm" filename\`) but got an IOError, assuming that I am in a different time zone from UTC and wanted to set the timestamp of a file…

---

## [Convert string containing quotes to command](https://discourse.julialang.org/t/convert-string-containing-quotes-to-command/101334)

<div class="topic-metadata">

**Author:** [@maths.tex](https://discourse.julialang.org/u/maths.tex)\
**Replies:** 5\
**Last updated:** [July 28, 2023, 9:46pm UTC](https://discourse.julialang.org/t/convert-string-containing-quotes-to-command/101334 "2023-07-28T21:46:49Z")

</div>

I’m new to julia. I have the following strings readen from a json file: pathtoexe = “c:\\my soft\\myexe.exe” folder = “c:\\folder with spaces” mycommand= “‘pathtoexe’ /option /D=‘folder’” The following commands replace …

---

## [Capture stdout and stderr in case a command fails](https://discourse.julialang.org/t/capture-stdout-and-stderr-in-case-a-command-fails/101772)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 2\
**Last updated:** [July 19, 2023, 8:59am UTC](https://discourse.julialang.org/t/capture-stdout-and-stderr-in-case-a-command-fails/101772 "2023-07-19T08:59:11Z")

</div>

What is the current recommended pattern for capturing the output of stdout and stderr of a command? I tried something like log = IOBuffer() redirect\_stdio(; stdout = log, stderr = log) do if success(cmd) no…

---

## [How to read from external command and also get exit status](https://discourse.julialang.org/t/how-to-read-from-external-command-and-also-get-exit-status/99880)

<div class="topic-metadata">

**Author:** [@djvanderlaan](https://discourse.julialang.org/u/djvanderlaan)\
**Replies:** 2\
**Last updated:** [June 5, 2023, 1:33pm UTC](https://discourse.julialang.org/t/how-to-read-from-external-command-and-also-get-exit-status/99880 "2023-06-05T13:33:36Z")

</div>

I would like to run an external command an get its output str = read(\`ls -al\`, String) works for reading the output. However, I have a command that can also give non-zero exit codes on what I consider successful execut…

---

## [Interpolating multiple parameters into a Cmd](https://discourse.julialang.org/t/interpolating-multiple-parameters-into-a-cmd/97709)

<div class="topic-metadata">

**Author:** [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Replies:** 2\
**Last updated:** [April 20, 2023, 3:32pm UTC](https://discourse.julialang.org/t/interpolating-multiple-parameters-into-a-cmd/97709 "2023-04-20T15:32:39Z")

</div>

Thank you Steven. Raising this topic from the dead. In my scenario, concatenation of the command fails, as I get single apostrophes in the command that I don’t want, see my first comment. Any ideas how I can avoid thi…

---

## [Convert string into Cmd object](https://discourse.julialang.org/t/convert-string-into-cmd-object/81691)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 2\
**Last updated:** [May 26, 2022, 1:48am UTC](https://discourse.julialang.org/t/convert-string-into-cmd-object/81691 "2022-05-26T01:48:04Z")

</div>

How can i convert a string like "command arg1 arg2 --opt1=value --flag" into a Cmd object and run that command?

---

## [Escaping properly a bash command](https://discourse.julialang.org/t/escaping-properly-a-bash-command/81316)

<div class="topic-metadata">

**Author:** [@roi.holtzman](https://discourse.julialang.org/u/roi.holtzman)\
**Replies:** 1\
**Last updated:** [May 19, 2022, 5:00pm UTC](https://discourse.julialang.org/t/escaping-properly-a-bash-command/81316 "2022-05-19T17:00:20Z")

</div>

I am trying to execute a command which has its own variable. Specifically, I am trying to submit jobs on a cluster using Njobs = 10 for r in res submit = \`bsub -R 'rusage\[mem=800\]' -J jobname\\\[1-$Njobs\\\] julia\_scri…

---

## [How to pass arguments to Cmd?](https://discourse.julialang.org/t/how-to-pass-arguments-to-cmd/73959)

<div class="topic-metadata">

**Author:** [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Replies:** 5\
**Last updated:** [January 3, 2022, 5:22pm UTC](https://discourse.julialang.org/t/how-to-pass-arguments-to-cmd/73959 "2022-01-03T17:22:47Z")

</div>

For example I might call \`echo\` with argument "hello", how can I do it? Assume cmd = \`eho\` , I found that push!(cmd.exec, "hello" does the trick, but exec is not documented, is this recommended? Also, run from Base has …

---

## [Better support for running external commands](https://discourse.julialang.org/t/better-support-for-running-external-commands/44933)

<div class="topic-metadata">

**Author:** [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Replies:** 39\
**Last updated:** [October 25, 2021, 10:43am UTC](https://discourse.julialang.org/t/better-support-for-running-external-commands/44933 "2021-10-25T10:43:28Z")

</div>

Currently, in Julia the run function is not as stable as the rest of the Julia. You can’t run external commands with special characters. The different behavior of Cmd from String makes using it inconvenient. Windows sup…

---

## [Change directory before running an external command](https://discourse.julialang.org/t/change-directory-before-running-an-external-command/59479)

<div class="topic-metadata">

**Author:** [@curious](https://discourse.julialang.org/u/curious)\
**Replies:** 2\
**Last updated:** [April 17, 2021, 3:11pm UTC](https://discourse.julialang.org/t/change-directory-before-running-an-external-command/59479 "2021-04-17T15:11:52Z")

</div>

I have a julia file, say FileIwantToRun.jl in many folders/directories. I want to write a script that visits each of these directories and runs this file from those directories (it outputs a file that I want it to save i…

---

## [IOError: could not spawn 'cmd' : no such file or directory \<ENOENT\>](https://discourse.julialang.org/t/ioerror-could-not-spawn-cmd-no-such-file-or-directory-enoent/55898)

<div class="topic-metadata">

**Author:** [@abbasn110](https://discourse.julialang.org/u/abbasn110)\
**Replies:** 5\
**Last updated:** [February 24, 2021, 3:05pm UTC](https://discourse.julialang.org/t/ioerror-could-not-spawn-cmd-no-such-file-or-directory-enoent/55898 "2021-02-24T15:05:08Z")

</div>

hi Im kinda new on Julia. While working on REPL, when I want to switch to cmd and type it on Shell I get this error. IOError: could not spawn ‘cmd’ : no such file or directory I also added installation directory to en…

---

## [External program with string argument interpolation](https://discourse.julialang.org/t/external-program-with-string-argument-interpolation/47134)

<div class="topic-metadata">

**Author:** [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Replies:** 8\
**Last updated:** [September 24, 2020, 7:40am UTC](https://discourse.julialang.org/t/external-program-with-string-argument-interpolation/47134 "2020-09-24T07:40:48Z")

</div>

Hi, I can’t figure how (after reading https://docs.julialang.org/en/v1/manual/running-external-programs/manual) to run a command with string arguments enclosed with “” Le’s say the shell command I want to invoke is s…

---

## [Screenshots with package or cmd tool](https://discourse.julialang.org/t/screenshots-with-package-or-cmd-tool/46158)

<div class="topic-metadata">

**Author:** [@noroskir](https://discourse.julialang.org/u/noroskir)\
**Replies:** 1\
**Last updated:** [September 7, 2020, 9:57am UTC](https://discourse.julialang.org/t/screenshots-with-package-or-cmd-tool/46158 "2020-09-07T09:57:38Z")

</div>

Hello there ! Is there a native Julia package to take a screenshot? Alternatively does anybody know if it is possible to read the output of a cmd tool like xwd ( X Window Dump ) directly into a Julia object ? Thanks! …

---

## [Shell escaping](https://discourse.julialang.org/t/shell-escaping/28087)

<div class="topic-metadata">

**Author:** [@phlavenk](https://discourse.julialang.org/u/phlavenk)\
**Replies:** 1\
**Last updated:** [August 28, 2019, 8:35am UTC](https://discourse.julialang.org/t/shell-escaping/28087 "2019-08-28T08:35:13Z")

</div>

How to run a command with \* without getting warning about command misuse? run(\`attrib -r $projectworkdir\\\\\*.\* /s\`) #clearing readonly attribs ┌ Warning: special characters "#{}()\[\]\<\>|&\*?~;" should now be quoted in comma…
