# Changing default shell for "execute\_command\_line" subroutine

**URL:** <https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747>\
**Category:** Help\
**Created:** [May 5, 2023, 11:38am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747 "2023-05-05T11:38:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [May 5, 2023, 11:38am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/1 "2023-05-05T11:38:58Z")

</div>

I’m trying to convert some of my old bash scripts to Fortran. To accomplish this, I’m utilizing the `execute_command_line` subroutine. However, this subroutine uses the `sh` shell by default on Linux, and I want it to use `bash` instead. Is there a way to change the default shell used by the `execute_command_line` subroutine from `sh` to `bash`?

---

<div class="post-metadata">

**Author:** ![nshaffer](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nshaffer/32/161_2.png) [@nshaffer](https://fortran-lang.discourse.group/u/nshaffer)\
**Post date:** [May 5, 2023, 12:04pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/2 "2023-05-05T12:04:46Z")

</div>

Does it work to call bash explicitly? Instead of `call execute_command_line("./myscript")`, I am thinking `call execute_command_line("bash myscript")`.

Adding some details might get you other solutions. Does your script have a shebang for bash at the top?

---

<div class="post-metadata">

**Author:** ![PierU](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pieru/32/1848_2.png) [@PierU](https://fortran-lang.discourse.group/u/PierU)\
**Post date:** [May 5, 2023, 12:23pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/3 "2023-05-05T12:23:02Z")

</div>

> [@nshaffer](#):
>
> `call execute_command_line("bash myscript")`.

Rather `call execute_command_line("/bin/bash myscript")`, I think

But the sheebang solution looks better

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [May 5, 2023, 1:38pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/4 "2023-05-05T13:38:16Z")

</div>

Most shells have a -c option; so you can call “bash -c ‘ls;pwd;date’” for example. In POSIX environments something like [GitHub - urbanjost/M\_process: read or write to a process from Fortran via a C wrapper](https://github.com/urbanjost/M_process) might be useful. Note  
that on a lot of systems “sh” is a link to “bash” nowadays. Some compilers used to use whatever  
the $SHELL environment variable was set to but I think they all now start with essentially “sh”.

It really would be nice if execute\_command\_line(3f) called the equivalent of popen(c). One advantage of several is that you can change the environment for subsequent commands easily. To do that without creating a file (as already mentioned) ULS systems have the env(1) command, which makes it clear you are setting variables first. This can be a good idea to make sure the commands are using a specific command search path and timezone variable, for example:

```
  call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c "echo $HOME;ls;pwd")

```

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [May 20, 2023, 9:00am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/5 "2023-05-20T09:00:35Z")

</div>

@nshaffer, @PierU, and @urbanjost, thank you for your helpful answers, and I apologize for my delayed reply.

Actually, the exact issue I am facing is in this module: [forgnu](https://github.com/gha3mi/forgnu/blob/main/src/forgnu.f90), specifically in the `module_load` subroutine. I intend to use [Environmental Modules](https://github.com/cea-hpc/modules) to load the required modules. First, I need to set the module initialization script sourced from the shell configuration startup file:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'source /path/to/modules/5.2.0/init/bash'")

```

In the next step, I want to load the modules:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'ml gcc gdb'")

```

However, it doesn’t work because the initialization is defined in another shell.

If I execute the two commands at once as follows:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'source /path/to/modules/5.2.0/init/bash;ml gcc gdb'")

```

it works, but I want to execute them separately in two steps because my idea is to set the environments and load modules first and then use them.

---

<div class="post-metadata">

**Author:** ![PierU](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pieru/32/1848_2.png) [@PierU](https://fortran-lang.discourse.group/u/PierU)\
**Post date:** [May 20, 2023, 10:50am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/6 "2023-05-20T10:50:02Z")

</div>

I’m not sure of your exact objective, but you may create first a bash script file where to put your initializations, and execute this file later. Something like

```auto
open(newunit=lu,file="/anotherpath/to/myscript.bash")
write(lu,*) "#!/bin/bash"
write(lu,*) "TZ=0"
write(lu,*) "source /path/to/modules/5.2.0/init/bash"
close(lu)

```

and later

```auto
call execute_command_line("env PATH=/bin:/usr/bin; source /anotherpath/to/myscript.bash; ml gcc gdb'")

```

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [May 20, 2023, 11:20am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/7 "2023-05-20T11:20:53Z")

</div>

I am currently in the process of converting bash script files to Fortran in order to execute commands step by step directly within the Fortran code, without the need for generating a separate bash file. To achieve this, I am utilizing the `execute_command_line` subroutine.

To execute the commands directly in Fortran, I follow these steps. However, it doesn’t work!

1. Set the environmental modules using the following command:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'source /path/to/modules/5.2.0/init/bash'")

```

1. Load the required modules by executing the following command:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'ml gcc gdb'")

```

1. As an example, use gcc by calling the following command:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'gcc --version'")

```

The issue is that every time I want to use a specific command, such as gcc, I need to perform all three steps together at once:

```auto
call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'source /path/to/modules/5.2.0/init/bash;ml gcc gdb;gcc --version'")

```

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [May 20, 2023, 1:00pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/8 "2023-05-20T13:00:15Z")

</div>

Each time you call `execute_command_line()` you fork your current process to create a new child process. So the three commands are executed in three different processes.

The following code:

```fortran
  ! Show the pid of the processes:
  call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'echo $$'")
  call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'echo $$'")
  call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'echo $$'")
  call execute_command_line("env PATH=/bin:/usr/bin TZ=0 /bin/bash -c 'echo $$'")
  end

```

displays:

```bash
5680
5682
5684
5686

```

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [May 20, 2023, 1:21pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/9 "2023-05-20T13:21:09Z")

</div>

I think it is possible to create a _daemon shell script_ and to communicate with it. Maybe it could be a solution to your problem. But I can not help further…

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [May 20, 2023, 1:33pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/10 "2023-05-20T13:33:26Z")

</div>

This points directly to the problem I am currently facing.

---

<div class="post-metadata">

**Author:** ![Pap](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pap/32/1305_2.png) [@Pap](https://fortran-lang.discourse.group/u/Pap)\
**Post date:** [May 20, 2023, 2:00pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/11 "2023-05-20T14:00:37Z")

</div>

I believe it is safer to use

```auto
write(lu,*) "#!/bin/env bash"

```

instead of

```auto
write(lu,*) "#!/bin/bash"

```

This is because it won’t work otherwise, at least on some GNU/Linux systems, and definitely not in (Free)BSD.

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [May 20, 2023, 2:08pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/12 "2023-05-20T14:08:16Z")

</div>

Should be `#!/usr/bin/env bash`, at least on Unix.

---

<div class="post-metadata">

**Author:** ![Pap](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pap/32/1305_2.png) [@Pap](https://fortran-lang.discourse.group/u/Pap)\
**Post date:** [May 20, 2023, 2:25pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/13 "2023-05-20T14:25:02Z")

</div>

> [@interkosmos](#):
>
> Should be `#!/usr/bin/env bash`, at least on Unix.

That’s correct. Original post used `#!/bin/bash` which _will_ work in many GNU/Linux distributions (again, not all,) but won’t work at all in BSDs. I didn’t want to deviate much from the original, but the truth is `#!/usr/bin/env bash` should work everywhere - except perhaps the ones that don’t follow FHS (Filesystem Hierarchy Standard.)

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [May 20, 2023, 3:49pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/14 "2023-05-20T15:49:42Z")

</div>

Here are just some general comments about this issue.

First /bin/sh is now a link to /bin/bash on many systems. The shell looks at how it was invoked and behaves appropriately, but it is the same executable in both cases, it is just that the sh commands are emulated within bash. On MacOS, I think /bin/sh is now emulated within /bin/zsh, and that works the same way.

As you have determined, the problem with your approach is that the different invocations of `execute_command_line()` all work in different child processes, so you cannot execute a string of commands that all modify or operate within the same environment. This is not a special case for fortran, all shells and languages work the same way on a POSIX or unix-like system.

In POSIX systems, a child process inherits the environment of the parent. So if you modify the environment of the parent process, any subsequent child processes will start with those modifications. Fortran provides a `get_environment_variable()` intrinsic to query the current environment, but it does not provide an analogous `set_environment_variable()` to modify it. I don’t know why that function is missing in fortran, but it is.

So the workaround is to use the POSIX `setenv()` system call. Actually, all unix-like operating systems support this (going back to the 1980s), even if they are not POSIX compliant. You need to set up the appropriate fortran interface to this operating system function using C interop in order to invoke it directly from fortran. You do not need to write a C interface function, you can go directly from fortran to the OS call.

Once the environment has been modified, you can test if the change is correct with the fortran `get_environment_variable()` intrinsic. When that all works, then you can invoke separate `execute_command_line()` calls, and they will all begin with that modified environment.

Maybe someone can fill i some details if necessary, or correct me if I’m wrong about any of the above, but that is one possible way forward to solve your problem.

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [May 20, 2023, 11:43pm UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/15 "2023-05-20T23:43:16Z")

</div>

That is a work-around for setting the variables. There are other alternatives

If you only need to run on ULS that have popen(3c) you can start a process and write multiple lines to it. There are examples on the Fortran Wiki or see [GitHub - urbanjost/M\_process: read or write to a process from Fortran via a C wrapper](https://github.com/urbanjost/M_process) for another example.

You can create a FIFO file either with a system command or via a call to the appropriate C routines and start a shell that reads from it; and the write to it as needed.

You can gather up the lines instead of executing them and write them into a file and then execute all at once if the commands do not need executed at various times; as was mentioned above.

On machines that support it popen(3c) is a very nice way to go. There are equivalents on MSWindows to popen(3c) that you can use the same way, but I have not used them in ages.

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [May 22, 2023, 12:34am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/16 "2023-05-22T00:34:49Z")

</div>

FIFO files are highly underutilized in my opinion, and are easy to use from all the  
Unix/GNU-Linux systems as far as I know. MSWindows has FIFO files but this  
example only works on ULS but shows how a Fortran program (or pretty  
much any language that can write to a file) can open a shell and leave  
it open and then write to it like it was pretty much any other file:

> **Fortran Code**
>
> ```fortran
> program main
> ! example of using FIFO files instead of calling POPEN(3c)
> implicit none
> character(len=*), parameter :: g = '(*(g0))'
> integer :: lun, iostat
> !
> ! setup
> !
> ! assumes GNU commands rm, mkfifo, fuser, bash are available
> call run("rm -f __unique_name")
> call run("mkfifo __unique_name")
> ! start shell in background
> call run("bash -v < __unique_name 2>&1", wait=.false.)
> ! open fifo file for writing
> open (newunit=lun, file="__unique_name", action="write")
> !
> ! write commands to bash shell
> !
> call cmd('export PATH=/bin/:/usr/bin TZ=0',iostat)
> call cmd('uname -a;date;whoami',iostat)
> call cmd('source /path/to/modules/5.2.0/init/bash',iostat)
> call cmd('echo $HOME;pwd',iostat)
> call cmd('ml gcc gdb',iostat)
> call cmd('gcc --version',iostat)
> call cmd('cd /tmp',iostat)
> call cmd([character(len=256) :: 'pwd','echo note still in /tmp','printenv TZ;echo $PATH'])
> ! teardown
> close (unit=lun, iostat=iostat)
> call run("fuser -k __unique_name;rm -f__ unique_name")
> 
> contains
> elemental impure subroutine run(string,wait)
> ! call system command
> character(len=*), intent(in) :: string
> logical,intent(in),optional :: wait
> integer :: exitstat, cmdstat, iostat
> character(len=256) :: cmdmsg
> logical :: wait_
> if(present(wait))then; wait_=wait; else; wait_=.true.; endif
> call execute_command_line(string, wait=wait_,exitstat=exitstat,cmdstat=cmdstat,cmdmsg=cmdmsg)
> if (exitstat .ne. 0) write (*, g) '< ERROR:RUN: > ', trim(cmdmsg)
> end subroutine run
> 
> elemental impure subroutine cmd(string,iostat)
> ! write command to shell
> character(len=*), intent(in) :: string
> integer,intent(out),optional :: iostat
> integer :: iostat_
> character(len=256) :: iomsg
> write (lun, g, iostat=iostat_, iomsg=iomsg) string
> if (iostat_ .ne. 0) write (*, g) '< ERROR:CMD: > ', trim(iomsg)
> if(present(iostat))iostat=iostat_
> end subroutine cmd
> 
> end program main
> 
> ```

Just always remember to create your FIFO file in a private directory, as if you open it without correct permission modes other people that can write to the file can run as you; sort of a do-it-yourself su(1).’

As an experiment, this should load the code into the Fortran playground:

[playground](https://play.fortran-lang.org/?code=program%20main%0A%20%20%20%21%20example%20of%20using%20FIFO%20files%20instead%20of%20calling%20POPEN%283c%29%0A%20%20%20implicit%20none%0A%20%20%20character%28len%3D%2A%29%2C%20parameter%20%3A%3A%20g%20%3D%20%27%28%2A%28g0%29%29%27%0A%20%20%20integer%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20lun%2C%20iostat%0A%20%20%20%21%0A%20%20%20%21%20setup%0A%20%20%20%21%0A%20%20%20%21%20assumes%20GNU%20commands%20rm%2C%20mkfifo%2C%20fuser%2C%20bash%20are%20available%0A%20%20%20call%20run%28%22rm%20-f%20 __unique_name%22%29%0A%20%20%20call%20run%28%22mkfifo%20__ unique_name%22%29%0A%20%20%20%21%20start%20shell%20in%20background%0A%20%20%20call%20run%28%22bash%20-v%20%3C%20 __unique_name%202%3E%261%22%2C%20wait%3D.false.%29%0A%20%20%20%21%20open%20fifo%20file%20for%20writing%0A%20%20%20open%20%28newunit%3Dlun%2C%20file%3D%22__ unique_name%22%2C%20action%3D%22write%22%29%0A%20%20%20%21%0A%20%20%20%21%20write%20commands%20to%20bash%20shell%0A%20%20%20%21%0A%20%20%20call%20cmd%28%27export%20PATH%3D%2Fbin%2F%3A%2Fusr%2Fbin%20TZ%3D0%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27uname%20-a%3Bdate%3Bwhoami%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27source%20%2Fpath%2Fto%2Fmodules%2F5.2.0%2Finit%2Fbash%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27echo%20%24HOME%3Bpwd%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27ml%20gcc%20gdb%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27gcc%20--version%27%2Ciostat%29%0A%20%20%20call%20cmd%28%27cd%20%2Ftmp%27%2Ciostat%29%0A%20%20%20call%20cmd%28%5Bcharacter%28len%3D256%29%20%3A%3A%20%27pwd%27%2C%27echo%20note%20still%20in%20%2Ftmp%27%2C%27printenv%20TZ%3Becho%20%24PATH%27%5D%29%0A%20%20%20%21%20teardown%0A%20%20%20close%20%28unit%3Dlun%2C%20iostat%3Diostat%29%0A%20%20%20call%20run%28%22fuser%20-k%20 __unique_name%3Brm%20-f%20__ unique_name%22%29%0A%0Acontains%0A%20%20%20elemental%20impure%20subroutine%20run%28string%2Cwait%29%0A%20%20%20%21%20call%20system%20command%0A%20%20%20%20%20%20character%28len%3D%2A%29%2C%20intent%28in%29%20%20%20%20%3A%3A%20string%0A%20%20%20%20%20%20logical%2Cintent%28in%29%2Coptional%20%20%20%20%20%3A%3A%20wait%0A%20%20%20%20%20%20integer%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20exitstat%2C%20cmdstat%2C%20iostat%0A%20%20%20%20%20%20character%28len%3D256%29%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20cmdmsg%0A%20%20%20%20%20%20logical%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20wait_%0A%20%20%20%20%20%20if%28present%28wait%29%29then%3B%20wait_%3Dwait%3B%20else%3B%20wait_%3D.true.%3B%20endif%0A%20%20%20%20%20%20call%20execute_command_line%28string%2C%20wait%3Dwait_%2Cexitstat%3Dexitstat%2Ccmdstat%3Dcmdstat%2Ccmdmsg%3Dcmdmsg%29%0A%20%20%20%20%20%20if%20%28exitstat%20.ne.%200%29%20write%20%28%2A%2C%20g%29%20%27%3C%20ERROR%3ARUN%3A%20%3E%20%27%2C%20trim%28cmdmsg%29%0A%20%20%20end%20subroutine%20run%0A%0A%20%20%20elemental%20impure%20subroutine%20cmd%28string%2Ciostat%29%0A%20%20%20%21%20write%20command%20to%20shell%0A%20%20%20%20%20%20character%28len%3D%2A%29%2C%20intent%28in%29%20%3A%3A%20string%0A%20%20%20%20%20%20integer%2Cintent%28out%29%2Coptional%20%3A%3A%20iostat%0A%20%20%20%20%20%20integer%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20iostat_%0A%20%20%20%20%20%20character%28len%3D256%29%20%20%20%20%20%20%20%20%20%20%20%3A%3A%20iomsg%0A%20%20%20%20%20%20write%20%28lun%2C%20g%2C%20iostat%3Diostat_%2C%20iomsg%3Diomsg%29%20string%0A%20%20%20%20%20%20if%20%28iostat_%20.ne.%200%29%20write%20%28%2A%2C%20g%29%20%27%3C%20ERROR%3ACMD%3A%20%3E%20%27%2C%20trim%28iomsg%29%0A%20%20%20%20%20%20if%28present%28iostat%29%29iostat%3Diostat_%0A%20%20%20end%20subroutine%20cmd%0A%0Aend%20program%20main%0A)

---

<div class="post-metadata">

**Author:** ![Ali](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ali/32/751_2.png) [@Ali](https://fortran-lang.discourse.group/u/Ali)\
**Post date:** [May 22, 2023, 5:08am UTC](https://fortran-lang.discourse.group/t/changing-default-shell-for-execute-command-line-subroutine/5747/17 "2023-05-22T05:08:44Z")

</div>

@urbanjost , thank you for the great suggestion and the provided example. It works perfectly!  
I will test it out and get back to you with the results.
