ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi
Im having a few problems with a make file im writing. I run the make file as root, then i need to change to another user with 'su - user -c', source their .bash_profile and then in the new shell to execute a script as this user. Something like this (except the syntax doesn't work)
su - user -c ". ~/.bash_profile && $(dirpath)test2.sh"
I can't call the script from the .bash_profile either.
That syntax looks OK to me (maybe I'm just tired). One problem is that the shell may be interpreting $(dirpath) as a shell variable, which probably doesn't exist if it's set by your Makefile. You might do "echo $(dirpath)" in your su command string to verify this (I'm pretty sure this is your problem, but I'm not sure of an elegant way to fix it; depending on another user's shell environment is not really standard practive in any makefile I've seen).
Hi
Thanks for the reply, i changed the script to run a script in that users home dir (doing away with the $dirpath) and it still wouldn't work. Im always dropped in the new shell.
All i want to know how to do is to run a command like 'env -i bash' and then in the nice clean shell to execute another script. This surely is possible with make ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.