Bash - Return value from subscript to parent script -
i have 2 bash scripts. parent scripts calls subscript perform actions , return value. how can return value subscript parent script? adding return
in subscript , catching value in parent did not work.
i assuming these scripts running in 2 different processes, i.e. not "sourcing" 1 of them.
it depends on want return. if wish return exit code between 0 , 255 then:
# child (for example: 'child_script') exit 42 # parent child_script retn_code=$?
if wish return text string, have through stdout (or file). there several ways of capturing that, simplest is:
# child (for example: 'child_script') echo "some text value" # parent retn_value=$(child_script)
Comments
Post a Comment