I have a program (let's name it middle) which I can't modify.
This program performs the following sequence of steps:
middlesends some text to stdout (echo Text1)middleinvokes shell scriptinner.shpassing some text string (4 KBytes or less) as argument (inner.sh "Deferred Message")middlesends some text to stdout (echo Text2)
My task is to create two bash scripts outer.sh and inner.sh to arrange deferred message after all the other messages generated by middle process.
The resulting stdout must be the following:
Text1 Text2 Deferred Message The requirements:
outer.shshould invokemiddle(andmiddlewill invokeinner.sh).inner.shmust remember its argument (deferred message) somewhere- After
middleis terminated,outer.shmust recall the deferred message and print it to stdout - There will be a lot of
outer.shprocesses running simultaneously. The deferred message must be stored in a place which is local to current instance ofouter.shprocess - Creation of temporary objects in file system is prohibited. (Is it possible to store the deferred message somewhere in memory?)
inner.sh
# Where should I save message "$1"? outer.sh
middle "$@" # How should I recall and print the deferred message? Where should I save the deferred message in child process and how to read it back in parent process?