On Tuesday, July 23, 2002, at 12:14 , Mayank Ahuja wrote:
[..]
> Putting it graphically,
>
>
>       A
>       |
>       |
>       |-------
>       |      |
>       |      B
>       |    (New Terminal)
>       |    [User sets a variable]
>       |
>       |
>    (execution of the script continues once B is over)
>
>
> Is there a way by which Shell A can come to know of the value of the
> variable set in B?
[..]

yes, but it will not be easy....

Bob has covered most of the normal ways.

> I don't know anything about IPC...can it work in this scenario?

This is a part of what you have opted to learn about - since
you are in the game of "Inter Process Communication".

so you will want to start with perldoc perlipc at some point in here.

In the dark old days we did this all with 'named files'

        PID=$$
        FILE="/tmp/me.$PID"

        # make sure it is GONE before we call our player
        [ -f $FILE ] && /bin/rm $FILE

        #
        # we will block here until MyOtherScript finishes
        #       and it will leave the answer in the File we pass it
        #
        MyOtherScript $FILE

        if [ -f $FILE ]
        then
                WORD_UP=`cat $FILE`
                /bin/rm $FILE
        else
                echo "We be scrawed - no file"
                exit
        fi

        #
        # your answer is in $WORD_UP
        #

This allowed us the simple tricks that MyOtherScript could use
STDOUT/STDIN as expected, but would end up writing out the final
answer to the file and we would read that file for the answer.

most folks have seen that as

        ps -ef > /tmp/SomeFile

        awk '<awkstuff>' /tmp/SomeFile

and then push both into a shell script and then into the

        ANSWER=`ps -ef | awk '<awkstuff>' `

This is the single most UGLIEST way to solve it - but it is,
essentially the start into the abyss of doing IPC - from here
it goes into PIPES, FIFO's, socket handling... technical bits.

{ you will be eaten by BEAST CREATURES if you use a /bin/sh script
to invoke mknod to set up a named pipe.... trust me, do not
go there, that way leads to madness.... }

What you will want to do is get out of the File IO game and
learn to launch a child that opens up a connection back to
mother to write straight back - and mom just sits there
spinning the blondie classic

        hanging on the telephone

waiting for word up to arrive....



ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to