0

I came across this problem now several times and I would like to find a way to automate/script this things that involves a change of identity or environment (I am not sure how to call that precisely).

An easy example would be a script where a part has to be executed with su. (make install for instance). To achieve this one could use sudo. However there are other environment changes that do not have such an escape solution. Probably well known is the python virtualenv where one could easily imagine a script like

source virtEnv/bin/activate
python myScript.py

or simply a script that invokes screen. Now I am compiling gstreamer which I would like to automate in a script, because I will have to deploy this installation in several other computers later

for i in gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-python gnonlin gst-ffmpeg 
do
   gst-head
   cd ./$i
   git checkout tags/1.1.1
   ./autogen.sh
   make -j7
   exit
done

Where gst-head is the gst-uninstalled script that loads a local pkg_config (if I am right) and puts me in a separate environment. If I put that in a script the script will stop its execution there and continues once I do exit from that environment.

1
  • I'm not sure what your problem here is. Is make not executed? What does not work in the script you have posted?
    – terdon
    Jul 10, 2013 at 15:10

1 Answer 1

0

That "environment" where the script "puts you", is a new instance of your shell actually. And instead of simply calling gst-head without a parameter, you should pass the commands as arguments! Can you see this part in the script?

# if we got a command, run it, else start a shell
if test ! -z "$1";
then
  $@
  exit $?
fi

I think you should try to make use of it. BTW, if you want to start a shell at all costs, then you won't be able to interact with it unless you use expect, in some way (either a standalone expect script or embedded into a shell script).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .