# Redirect the error output of an AppleScript called through Cmd

**URL:** <https://discourse.julialang.org/t/redirect-the-error-output-of-an-applescript-called-through-cmd/123825>\
**Category:** General Usage\
**Tags:** shell\
**Created:** [December 13, 2024, 9:47pm UTC](https://discourse.julialang.org/t/redirect-the-error-output-of-an-applescript-called-through-cmd/123825 "2024-12-13T21:47:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [December 13, 2024, 9:47pm UTC](https://discourse.julialang.org/t/redirect-the-error-output-of-an-applescript-called-through-cmd/123825/1 "2024-12-13T21:47:20Z")

</div>

The next question (for background see [Interpolate into an AppleScript called through Cmd](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824)).

When calling AppleScript from the shell, the redirection works as expected:

```julia
eben60@Macmini ~ % osascript -e 'POSIX path of (choose folder with prompt "Pick a folder:")'             
2024-12-13 22:29:28.938 osascript[92280:10059569] +[IMKClient subclass]: chose IMKClient_Modern
/Users/eben60/Downloads/2023/

```

Without redirection: the line starting with 2024-12-13 is “log noise”, the third line is the directory selected.

```julia
eben60@Macmini ~ % osascript -e 'POSIX path of (choose folder with prompt "Pick a folder:")' 2> /dev/null
/Users/eben60/Downloads/2023/

```

With redirection: the error/warning/log message disappears in /dev/null as expected.

* * *

Now the same from Julia shell:

```julia
julia> script12 = """POSIX path of (choose folder with prompt "Pick a folder:")""";

julia> r12 = readchomp(`osascript -e $script12 2\> /dev/null`); # dialog opens
2024-12-13 22:39:12.192 osascript[92481:10066803] +[IMKClient subclass]: chose IMKClient_Modern

julia> r12
"/Users/eben60/Downloads/2023/"

```

Redirection ignored ☹

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [December 13, 2024, 11:45pm UTC](https://discourse.julialang.org/t/redirect-the-error-output-of-an-applescript-called-through-cmd/123825/2 "2024-12-13T23:45:03Z")

</div>

Redirection doesn’t work like that in Cmd literals. See the IO redirection section here:

> **[Running External Programs · The Julia Language](https://docs.julialang.org/en/v1/manual/running-external-programs/#Pipelines)**
>
> Documentation for The Julia Language.
