# Is there a Julia command line equivalent of \`python -m python\_package\_name\`

**URL:** https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604
**Category:** General Usage
**Tags:** question
**Created:** [June 11, 2022, 4:54pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604 "2022-06-11T16:54:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![djpasseyjr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djpasseyjr/32/23695_2.png) [@djpasseyjr](https://discourse.julialang.org/u/djpasseyjr)
#### Post date: [June 11, 2022, 4:54pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604/1 "2022-06-11T16:54:44Z")

</div>

In Python, packages may have a ` __main__.py` file. If they do you can [execute the code inside of this file in the command line](https://riptutorial.com/python/example/18555/making-package-executable) by using:

`python -m python_package_name`.

It can also accept arguments:

`python -m python_package_name arg1 arg2`.

This is useful for using python packages in shell scripts.

I know about `julia -e "some_julia_code"` but it would be nice if I didn’t have to write the Julia code in the shell or point to a julia file containing the code I want to execute. Does Julia have something similar?

---

<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: [June 11, 2022, 4:59pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604/2 "2022-06-11T16:59:55Z")

</div>

Well, you have to do something like:

```julia
julia -e "using julia_package_name; main()"

```

if you want to load a package and execute the function main() of the package. Not so different, and no special syntax required.

---

<div class="post-metadata">

### Author: ![djpasseyjr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djpasseyjr/32/23695_2.png) [@djpasseyjr](https://discourse.julialang.org/u/djpasseyjr)
#### Post date: [June 11, 2022, 5:01pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604/3 "2022-06-11T17:01:24Z")

</div>

Can this accept command line arguments?

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [June 11, 2022, 5:03pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604/4 "2022-06-11T17:03:41Z")

</div>

You can certainly pass arguments to a script from the command line, see [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)?

The arguments you pass will be available in the global variable `ARGS`. There are several packages that help with argument parsing should you need it.

Example:

```julia
$ julia -e "@show ARGS" 111
ARGS = ["111"]

```

You can replace the `-e "@show ARGS"` part here with your script file etc.

---

<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: [June 11, 2022, 7:49pm UTC](https://discourse.julialang.org/t/is-there-a-julia-command-line-equivalent-of-python-m-python-package-name/82604/5 "2022-06-11T19:49:35Z")

</div>

You can create a simple shell script and put in a folder which is on your `PATH` variable.

For example, for unix the script will be something like:

```bash
#!/bin/bash
package="$1"
arguments="${@:2}"
exec julia -q -e "using $package; $package.main()" $arguments

```

Naming the script `juliap`, you can use like:

```julia
juliap SomePackage x y -z --foo

```

Not sure how to write this script on windows though.
