# Interpolate into an AppleScript called through Cmd

**URL:** <https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824>\
**Category:** General Usage\
**Tags:** shell, cmd\
**Created:** [December 13, 2024, 8:48pm UTC](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824 "2024-12-13T20:48:13Z")\
**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, 8:48pm UTC](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824/1 "2024-12-13T20:48:13Z")

</div>

The background: the NativeFileDialog.jl unfortunately makes [problems](https://github.com/JuliaGraphics/NativeFileDialog.jl/issues/14) on MacOS 15 (i.e. current version). I’m trying to put together a workaround.

This one actually works:

```julia
cmd1 = `osascript -e 'POSIX path of (choose file with prompt "Pick a file:")' 2\> /dev/null`; 
# sending log noise to /dev/null

r1 = readchomp(cmd1) ;

```

([on log noise on MacOS 15](https://discussions.apple.com/thread/255761734?sortBy=rank) )

This one works too:

```julia
cmd3 = `osascript -e 'set strPath to POSIX file "/Users/eben60/Downloads/2023/"
POSIX path of (choose file with prompt "Pick a file:" default location strPath)' 2\> /dev/null`

r3 = readchomp(cmd3) ;

```

Now, I’d like to replace the hardwired default location by a programmable one. Like this:

```julia
default = "Users/eben60/Downloads/2023/"

cmd5 = `osascript -e 'set strPath to POSIX file "$default"
POSIX path of (choose file with prompt "Pick a file:" default location strPath)' 2\> /dev/null`

r5 = read(cmd5, String) ;

```

That doesn’t work. `$default"` will not be expanded at this position. And none of the workarounds I could think of (e.g. putting the quotation marks into the `default` variable) worked. Any ideas?

---

<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, 8:57pm UTC](https://discourse.julialang.org/t/interpolate-into-an-applescript-called-through-cmd/123824/2 "2024-12-13T20:57:08Z")

</div>

Build the script as a string, then pass that string to `osascript`.

```julia
script = """ set strPath to POSIX file "$default"
POSIX path of (choose file with prompt "Pick a file:" default location strPath)
"""
read(`osascript -e $script`, String)

```
