Python task output to an input to shell task

How to pass python task output to an input to shell task
Python task name is PR_US
I created below variable in shell script to store result of PR_US
target_host = morpheus[‘results’][‘PR_US’]

Hi Paul,

Please find the doc link Task Results — Morpheus Docs documentation
Please find the video explanation for the above.
https://www.youtube.com/watch?v=UiVp2BTYwU4

python Source Task with code sourceTask

import socket

def get_hostname():
    return socket.gethostname()

if __name__ == "__main__":
    hostname = get_hostname()
    print("Hostname:", hostname)

shell Result task
echo "single: <%=results.sourceTask%>"

if you have added the 2 tasks in an operational workflow and executed the workflow you can see the source task returns “Hostname: xyz” and the Result task returns “single: Hostname: xyz”

Thanks
Velan

1 Like