how to get a command output to the variable?

In my pipeline I sometimes just want to get the command output as an output of the task as sometimes it is just one line and writing it to the file looks like a huge overhead for me. Unfortunately in current wdl documentation I do not see how to do it.

Tagged:

Answers

  • KateNKateN Cambridge, MAMember, Broadie, Moderator admin

    I'm having trouble understanding what it is you are looking to do. Could you provide an example?

  • mmahmmah Member, Broadie ✭✭

    This sample workflow demonstrates how to read from standard output to a WDL string. I think you are interested in the task simple_read_string.

    workflow sample{
        call simple_read_string{}
        call pushout { input : in = simple_read_string.out}
    }
    
    task simple_read_string{    
        command{
            echo "testing"
        }
        output{
            String out = read_string(stdout())
        }
    }
    
    task pushout{
        String in
        command{
            echo ${in}
        }
    }
    

    Be aware that:
    1. If your backend writes to standard output (as LSF does for me) in addition to your program's output, parsing the combined result may be more difficult than writing a new file.
    2. Cromwell writes many files including stdout and stderr for every task, so an additional file is likely not significant additional overhead.

Sign In or Register to comment.