# A small package to run string as shell command

**URL:** https://discourse.julialang.org/t/a-small-package-to-run-string-as-shell-command/6163
**Category:** General Usage
**Tags:** package, shell
**Created:** [September 30, 2017, 8:36am UTC](https://discourse.julialang.org/t/a-small-package-to-run-string-as-shell-command/6163 "2017-09-30T08:36:32Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 30, 2017, 1:01pm UTC](https://discourse.julialang.org/t/a-small-package-to-run-string-as-shell-command/6163/5 "2017-09-30T13:01:55Z")

</div>

> [@innerlee](#):
>
> `run("convert $r/*.png $(basename(r)).mp4")`

Note that doing this sort of thing has all of the problems that @StefanKarpinski described in his [Shelling Out Sucks](https://julialang.org/blog/2012/03/shelling-out-sucks) blog post. It will have unexpected results if `basename(r)` contains spaces, for example. (Maybe this is what @yuyichao was referring to with “buggy code”.) That’s why it would be better to learn to use `Cmd` objects.

The main thing that can’t be done directly with `Cmd` objects in this example is the `*.png` globbing ([implement more special shell-like functionality in backticks · Issue #20401 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/20401)). However, you can use the [Glob.jl](https://github.com/vtjnash/Glob.jl) package for that:

```julia
using Glob
run(`convert $(glob("*.png", r)) $(basename(r)).mp4`)

```

---

_[View the full topic](https://discourse.julialang.org/t/a-small-package-to-run-string-as-shell-command/6163)._
