LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2005, 05:34 PM   #1
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Rep: Reputation: 15
make problem with su


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.

Is this possible, and if so how can i do it ?

Thanks
 
Old 03-16-2005, 10:59 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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).
 
Old 03-17-2005, 06:17 AM   #3
dave bean
Member
 
Registered: Jun 2003
Location: UK
Distribution: Slackware 9.1
Posts: 136

Original Poster
Rep: Reputation: 15
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 ?

su - user -c "env -i bash && $(dirpath)test2.sh"

thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
make xconf;make gconf problem Soqool Linux - Newbie 3 06-12-2005 12:00 PM
Problem with Configure, Make, Make Install n8tgc Linux - Newbie 2 07-13-2004 03:16 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM
make clean, make dep problem carscht Linux - Newbie 2 02-21-2004 10:32 AM
make dep,make clean,make bzImage problem Babba Linux - Newbie 2 01-08-2003 03:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration