LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 05-25-2004, 02:28 AM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 338

Rep: Reputation: 30
Switch to another user, get his env and run a command 'under his name'


I tried using:

su - user2 -c "echo $my_personal_variable"

where "my_personal_variable" is defined in user2's environment. However, to my dismay, this produced no output and i concluded that using su - * -c doesn't import the user's env variables. Are there any workarounds for this? Mind you - I'm using Solaris/Bash (but i think this still applies on Linux boxes)

ganninu.
 
Old 05-25-2004, 01:58 PM   #2
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 52
If you want to run a command 'under his name' why not just use:
su - user2

and then run the command from there?
 
Old 05-25-2004, 02:26 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,623
Blog Entries: 10

Rep: Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773Reputation: 773
su - user2 -c 'echo $PWD'
for instance works here ...


Cheers,
Tink

Last edited by Tinkster; 05-25-2004 at 02:28 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
chroot: cannot run command `/tools/bin/env': No such file or directory Basel Linux From Scratch 5 06-30-2006 03:00 AM
run command as user BFEINZIMER Linux - Newbie 9 08-24-2005 10:21 PM
KDE 'switch user' command not appearing fyhuang Linux - Software 3 07-10-2005 03:04 AM
How to run a command on new mail for a user? pembo13 Linux - Networking 0 09-26-2004 07:37 AM
run command as alternate user joeca Linux - General 1 08-06-2003 04:31 PM


All times are GMT -5. The time now is 12:04 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration