# Cannot find output of run() command

**URL:** <https://discourse.julialang.org/t/cannot-find-output-of-run-command/50788>\
**Category:** New to Julia\
**Tags:** shell\
**Created:** [November 26, 2020, 1:34am UTC](https://discourse.julialang.org/t/cannot-find-output-of-run-command/50788 "2020-11-26T01:34:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruysan](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@ruysan](https://discourse.julialang.org/u/ruysan)\
**Post date:** [November 26, 2020, 1:34am UTC](https://discourse.julialang.org/t/cannot-find-output-of-run-command/50788/1 "2020-11-26T01:34:08Z")

</div>

Hi!  
I am generating a shell cut command with a series of arguments parsed from a file header.  
the output of the command it redirected to a file:

```nohighlight
cut -f 1-9,14,15 input_file > output_file

```

I can print the command itself into a file called mycutcommand.sh and attempt to run it from Julia:

```julia
run(`sh mycutcommand.sh`)

```

The script finishes with ProcessExited(0) but the output file is nowhere to be found. If I run the shell command directly it works OK. What am I doing wrong?

Here is the complete script:

```julia
query = readlines(ARGS[1]) #selected sample names
samplearray = split(read(pipeline(`head -11 $(ARGS[2])`,`tail -1`),String),r"\t")
mycutcommand = "cut -f 1-9,"

for i in query
    global mycutcommand = mycutcommand * string(findall(j -> j == i, samplearray)[1]) * "," 
end

myc = replace(mycutcommand, r",$" => " ") * string(ARGS[2]) * " > select.vcf"
commandfile = open("cutcommand.sh","w")
write(commandfile,myc)
mycmd = run(`sh ./cutcommand.sh`)

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [November 26, 2020, 2:28am UTC](https://discourse.julialang.org/t/cannot-find-output-of-run-command/50788/2 "2020-11-26T02:28:19Z")

</div>

First of all, welcome to out community.

Second, this seems like a terribly contrived way of doing it. Why do you not either write the script in Bash, or in Julia, what is the reason for programmatically creating a Bash script from Julia?

Third, I am not sure of the solution for your specific problem, if you can disclose some sample data you are using it may be easier to debug.

---

<div class="post-metadata">

**Author:** ![ruysan](https://avatars.discourse-cdn.com/v4/letter/r/c77e96/32.png) [@ruysan](https://discourse.julialang.org/u/ruysan)\
**Post date:** [January 27, 2021, 2:33am UTC](https://discourse.julialang.org/t/cannot-find-output-of-run-command/50788/3 "2021-01-27T02:33:41Z")

</div>

Hi! Thanks, I ended doing the whole process within Julia, and avoided using shell calls.
