fork - Pass variable from a child to parent in KSH -


i have work ksh (yeah hell shell). need use fork, subroutine following:

    #!/bin/ksh      pipe=pipe_$$     pipe_err=pipe_err_$$      export test_fils      $(. ./lancefils.ksh 2>${pipe_err} 1>${pipe}) &     pid_child=$!     echo "nom du fichier pipe: ${pipe}"     echo "processus fils : " $!     wait ${pid_child}      echo "code retour: " $?     echo "sortie standard de proc_fils : " $(cat ${pipe})     echo "sortie d'erreur(s) de proc_fils : " $(cat ${pipe_err})      echo "contenu de test_fils: ${test_fils}"     rm -rf ${pipe} 

content of lancefils.ksh

    #!/bin/ksh      timeout=5      export test_fils      echo "je suis le script fils et j'attends ${timeout} secondes"      echo "nom du pipe du pere ${pipe}"     sleep ${timeout}      test_fils="je suis le fils"     echo "salut c'était bien !!!"     exit 10 

i know not work, btw try find way make works ... in code can see want share test_fils variable between child , parent. there way in ksh share variable, in perl using "share" or if have use pipe in c ?

thank you.

variables can passed parent shell child shell, not other way around. however, can workaround if in need of value set in child shell.

one possible workaround: in child shell, write env variables of interest along values file. once in parent shell, run file env variables needed overwritten set in file. can refer here example.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -