# Execute\_command\_line problem

**URL:** <https://fortran-lang.discourse.group/t/execute-command-line-problem/7151>\
**Category:** Help\
**Created:** [January 9, 2024, 10:49pm UTC](https://fortran-lang.discourse.group/t/execute-command-line-problem/7151 "2024-01-09T22:49:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [January 10, 2024, 9:42am UTC](https://fortran-lang.discourse.group/t/execute-command-line-problem/7151/3 "2024-01-10T09:42:51Z")

</div>

This is the same behavior that one sees when recursive i/o is invoked. Based on that observation, if you change the main program to

```auto
   logical :: q
   q = iam('john')
   print "(A,L2)", 'I am john', q
   q = iam('JOHN')
   print "(A,L2)", 'I am JOHN', q

```

then I think the code will work (it does on MacOS+gfortran). Of course, the code is not doing recursive i/o, so this appears to be some kind of compiler or library bug.

[edit] I experimented a little more with this. It appears that the error has nothing to do with the `execute_command_line` intrinsic. If you comment out that call, the program still hangs. I also experimented a little with constructing the `cmd` string with substring indexing and assignments,

```auto
    cmd(1:18) = 'if [ `whoami` != "'
    cmd(18+1:18+len(name)) = name
    cmd(19+len(name):) = '" ]; then exit 1; fi'

```

and the program still hangs. If you eliminate `cmd`, and just insert the expression as the subroutine argument, it still hangs. I don’t see anything wrong with either the original code or any of these modified versions, they all look alright to my eye. One can disagree with the concept of executing functions just for side effects (i.e. a subroutine might be better), but the language allows this so it looks like it should work.

---

_[View the full topic](https://fortran-lang.discourse.group/t/execute-command-line-problem/7151)._
