Switching users in a bash script?
fn42551 at fmi.uni-sofia.bg
Sat Aug 26 12:27:09 PDT 2006
>> I had prepared a bash script to install the LFS system. A few days ago I decided that I need a package management system and I
>> to use package users. I'd also like to start from the ground up and build the whole LFS using package users. This means that I
>> to modify the long bash script that performs all the command in Chapter 6 of LFS 6.1.1 so that each package is installed as a
>> diferent user. And here comes the trouble - at some point in the script I need to switch from root to another (i.e. a package)
>> execute several of the commands that follow and return to the root user. This has to be done for every single package. Do I have
>> alternative that is better (and possibly easier) than extracting the commands that install a package in their own script and
>> 'su -c' in one "master" script?
> Write the script to execute as a user out, and pipe that into 'su'.
Could you please, explain this idea in a little bit more detail? Especially, how do I pipe commands into 'su'?
More information about the lfs-support