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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -