d

    DiffyBron

    2 years ago
    hello, i'm trying to run a shell and it seems that it only outputs one line when i perform 'ls -lat' is that an expected behavior? (I've taken bits and pieces from here : https://github.com/PrefectHQ/prefect/issues/1013
    from prefect import Flow, task
    from prefect.tasks.shell import ShellTask
    
    my_task = ShellTask(helper_script="cd /etc")
    
    @task
    def print_output(output):
      print(output)
    
    with Flow("My shell") as flow:
      result = my_task(command='ls -lat')
      print_output(result)
    
    if __name__ == '__main__':
        out = flow.run()
    Chris White

    Chris White

    2 years ago
    Yup that is expected; shell tasks only return the last line by default but that can be configured as described here: https://docs.prefect.io/api/unreleased/tasks/shell.html#shelltask
    d

    DiffyBron

    2 years ago
    perfect !