# How to run julia script as a command in the terminal?

**URL:** https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341
**Category:** General Usage
**Tags:** question
**Created:** [May 19, 2022, 10:42pm UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341 "2022-05-19T22:42:04Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dylanxyz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dylanxyz/32/36646_2.png) [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)
#### Post date: [May 19, 2022, 10:42pm UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/1 "2022-05-19T22:42:04Z")

</div>

I want to create some CLI applications in julia, but instead of the users writing (in the terminal):

```julia
julia --project /path-to/src/MyScript.jl arg1 --opt-1

```

I want to be able to type:

```julia
myscript arg1 --opt-1

```

---

<div class="post-metadata">

### Author: ![tsela](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsela/32/52174_2.png) [@tsela](https://discourse.julialang.org/u/tsela)
#### Post date: [May 20, 2022, 12:38am UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/2 "2022-05-20T00:38:37Z")

</div>

On UNIX-like OSes, create a shell script called `myscript` that passes its arguments to the Julia command, then make that script executable. On Windows, no idea how to do that, sorry.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [May 20, 2022, 1:03am UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/3 "2022-05-20T01:03:22Z")

</div>

Well, on Windows you can write a .bat file…

> **[How to create and run a batch file on Windows 10](https://www.windowscentral.com/how-create-and-run-batch-file-windows-10)**
>
> Batch files let you automate tasks, and in this guide, we'll show you how to use them on Windows 10.

---

<div class="post-metadata">

### Author: ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)
#### Post date: [May 20, 2022, 1:03am UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/4 "2022-05-20T01:03:24Z")

</div>

Take a look at this one in the FAQs [https://docs.julialang.org/en/v1/manual/faq/#How-do-I-pass-options-to-julia-using-#!/usr/bin/env](https://docs.julialang.org/en/v1/manual/faq/#How-do-I-pass-options-to-julia-using-#!/usr/bin/env)?

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [May 20, 2022, 1:41am UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/5 "2022-05-20T01:41:47Z")

</div>

You also may be interested in [ArgParse.jl](https://carlobaldassi.github.io/ArgParse.jl/stable/).

---

<div class="post-metadata">

### Author: ![dylanxyz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dylanxyz/32/36646_2.png) [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)
#### Post date: [May 20, 2022, 5:26am UTC](https://discourse.julialang.org/t/how-to-run-julia-script-as-a-command-in-the-terminal/81341/6 "2022-05-20T05:26:33Z")

</div>

I tested here, and we can actually create a .bat file that calls julia passing the correct arguments, and run it in the terminal like a normal command, assuming that the script is on a folder which is on PATH. Also, we can actually use the unix approach in Windows if the user uses git-bash (I use git-bash with zsh). Thanks everyone!
