text: user15246: Given two separate wdl arrays, my command section will do some modifications to each array and place the output into two separate bash arrays. Finally, I want to output the two separate bash arrays in the output section of the wdl task to be used in other tasks within the workflow.  The below code is an example of what I would like to do:
  task AddA {
      input {
          Array[String] wdllistX = [ "True", "False"]
          Array[String] wdllistY = [ "Good", "Food"]
      }
  
      command <<<
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
  
          bashX = ("Truea" Falsea")
          bashY = ("Gooda" "Fooda")
      >>>
      output {
          Array[String] finX = bashX
          Array[String] finY = bashY
      }
  }
  
  The above example produces an error. It seems that I might have to convert the bash arrays back into wdl arrays in order to declare them as outputs in the output section, however, I am not sure how to do this. May someone help me with this? Moreover, a general explanation of how you can capture the output of specific things from the command section into the output section would be helpful aswell.
  
  user7253: When a WDL task is run, the execution engine takes the command block and evaluates it as a template, rendering any wdl expressions it contains into the final script that is executed, BEFORE it is actually executed.
  The actual execution environment is generally isolated from the execution engine or from other tasks. Information is passed between tasks by reading from or passing around file based outputs and not from accessing the bash environment directly, which the engine does not have access to.
  So, in order to achieve what you are trying to do, you first need to get the values into a file format, and then you need to read those values using an engine function provided by WDL. Generally, all outputs need to be in a file if you want the engine to be able to interact with them. Please note that stdout and stderr are considered "files" and are accessible with stdout() and stderr() engine functions.
  Option 1: Construct json files and use read_json
  task AddA {
      input {
          Array[String] wdllistX = [ "True", "False"]
          Array[String] wdllistY = [ "Good", "Food"]
      }
  
      command <<<
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
          echo '["Truea","Falsea"]' > x.json
          echo '["Gooda","Fooda"]' > y.json
      >>>
      output {
          Array[String] finX = read_json("x.json")
          Array[String] finY = read_json("y.json")
      }
  }
  
  Option 2: use read_lines
  task AddA {
      input {
          Array[String] wdllistX = [ "True", "False"]
          Array[String] wdllistY = [ "Good", "Food"]
      }
  
      command <<<
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
  
          echo "Truea" >> x.txt
          echo "Falsea" >> x.txt
          echo "Gooda" >> y.txt
          echo "Fooda" >> y.txt
      >>>
      output {
          Array[String] finX = read_lines("x.txt")
          Array[String] finY = read_lines("y.txt")
      }
  }
  ```
  
  
original_text: 15246: <p>Given two separate wdl arrays, my command section will do some modifications to each array and place the output into two separate bash arrays. Finally, I want to output the two separate bash arrays in the output section of the wdl task to be used in other tasks within the workflow.  The below code is an example of what I would like to do:</p>
  <pre><code>task AddA {
      input {
          Array[String] wdllistX = [ &quot;True&quot;, &quot;False&quot;]
          Array[String] wdllistY = [ &quot;Good&quot;, &quot;Food&quot;]
      }
  
      command &lt;&lt;&lt;
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
  
          bashX = (&quot;Truea&quot; Falsea&quot;)
          bashY = (&quot;Gooda&quot; &quot;Fooda&quot;)
      &gt;&gt;&gt;
      output {
          Array[String] finX = bashX
          Array[String] finY = bashY
      }
  }
  </code></pre>
  <p>The above example produces an error. It seems that I might have to convert the bash arrays back into wdl arrays in order to declare them as outputs in the output section, however, I am not sure how to do this. May someone help me with this? Moreover, a general explanation of how you can capture the output of specific things from the command section into the output section would be helpful aswell.</p>
   7253: <p>When a WDL task is run, the execution engine takes the command block and evaluates it as a template, rendering any wdl expressions it contains into the final script that is executed, <strong>BEFORE</strong> it is actually executed.</p>
  <p>The actual execution environment is generally isolated from the execution engine or from other tasks. Information is passed between tasks by reading from or passing around file based outputs and not from accessing the bash environment directly, which the engine does not have access to.</p>
  <p>So, in order to achieve what you are trying to do, you first need to get the values into a file format, and then you need to read those values using an <a href="https://github.com/openwdl/wdl/blob/main/versions/1.1/SPEC.md#standard-library" rel="nofollow noreferrer">engine function provided</a> by <code>WDL</code>. Generally, all outputs need to be in a file if you want the engine to be able to interact with them. Please note that <code>stdout</code> and <code>stderr</code> are considered &quot;files&quot; and are accessible with <code>stdout()</code> and <code>stderr()</code> engine functions.</p>
  <h2>Option 1: Construct json files and use read_json</h2>
  <pre><code>task AddA {
      input {
          Array[String] wdllistX = [ &quot;True&quot;, &quot;False&quot;]
          Array[String] wdllistY = [ &quot;Good&quot;, &quot;Food&quot;]
      }
  
      command &lt;&lt;&lt;
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
          echo '[&quot;Truea&quot;,&quot;Falsea&quot;]' &gt; x.json
          echo '[&quot;Gooda&quot;,&quot;Fooda&quot;]' &gt; y.json
      &gt;&gt;&gt;
      output {
          Array[String] finX = read_json(&quot;x.json&quot;)
          Array[String] finY = read_json(&quot;y.json&quot;)
      }
  }
  </code></pre>
  <h2>Option 2: use read_lines</h2>
  <pre><code>task AddA {
      input {
          Array[String] wdllistX = [ &quot;True&quot;, &quot;False&quot;]
          Array[String] wdllistY = [ &quot;Good&quot;, &quot;Food&quot;]
      }
  
      command &lt;&lt;&lt;
          ###We add the letter 'a' at the end of each string in each wdl list and finally get the 
        bash arrays:
  
          echo &quot;Truea&quot; &gt;&gt; x.txt
          echo &quot;Falsea&quot; &gt;&gt; x.txt
          echo &quot;Gooda&quot; &gt;&gt; y.txt
          echo &quot;Fooda&quot; &gt;&gt; y.txt
      &gt;&gt;&gt;
      output {
          Array[String] finX = read_lines(&quot;x.txt&quot;)
          Array[String] finY = read_lines(&quot;y.txt&quot;)
      }
  }
  <span class="math-container">```</span>
  </code></pre>
  