Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

JAVA_HOME definition with su -

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
6 posts • Page 1 of 1
Author
Message
andreaske
n00b
n00b
Posts: 11
Joined: Wed Jan 11, 2006 10:44 am
Location: cologne/germany

JAVA_HOME definition with su -

  • Quote

Post by andreaske » Fri May 19, 2006 8:58 am

If I use the first example, JAVA_HOME is available. If I use the second example JAVA_HOME isn't defined. How or where i can define variables for the "su -" command?

Code: Select all

mwinst01 ~ # su - jboss
jboss@mwinst01 ~ $ set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="16" [3]="1" [4]="release" [5]="i686-pc-linux-gnu")
BASH_VERSION='3.1.16(1)-release'
COLUMNS=158
CONFIG_PROTECT_MASK=/etc/terminfo
CVS_RSH=ssh
DIRSTACK=()
EDITOR=/bin/nano
EUID=1000
GCC_SPECS=
GROUPS=()
HISTFILE=/home/jboss/.bash_history
HISTFILESIZE=500
HISTSIZE=500
HOME=/home/jboss
HOSTNAME=mwinst01
HOSTTYPE=i686
IFS=$' \t\n'
INFOPATH=/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/info:/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/info
JAVA_HOME=/opt/java/current
LESS='-R -M --shift 5'
LESSOPEN='|lesspipe.sh %s'
LINES=61
LOGNAME=jboss
LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.qt=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.flac=01;35:*.mp3=01;35:*.mpc=00;36:*.ogg=00;36:*.wav=00;36:*.mid=00;36:*.midi=00;36:*.au=00;36:*.flac=00;36:*.aac=00;36:'
MACHTYPE=i686-pc-linux-gnu
MAILCHECK=60
MANPATH=/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.16.1/man:/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/man
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PAGER=/usr/bin/less
PATH=/opt/java/current/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/3.3.6
PIPESTATUS=([0]="0")
PPID=13734
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
PS2='> '
PS4='+ '
PWD=/home/jboss
PYTHONPATH=/usr/lib/portage/pym
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
TERM=xterm
UID=1000
USER=jboss
_=/home/jboss/.bashrc

Code: Select all

mwinst01 ~ # su - jboss -c set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="16" [3]="1" [4]="release" [5]="i686-pc-linux-gnu")
BASH_VERSION='3.1.16(1)-release'
DIRSTACK=()
EUID=1000
GROUPS=()
HOME=/home/jboss
HOSTNAME=mwinst01
HOSTTYPE=i686
IFS=$' \t\n'
LOGNAME=jboss
MACHTYPE=i686-pc-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/bin:/usr/bin
PPID=13741
PS4='+ '
PWD=/home/jboss
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
TERM=xterm
UID=1000
USER=jboss
_=/bin/bash
Top
taciturnus
n00b
n00b
User avatar
Posts: 36
Joined: Tue Apr 05, 2005 6:43 am

  • Quote

Post by taciturnus » Fri May 19, 2006 2:35 pm

I assume jboss' shell is bash.

When you use

Code: Select all

$ su - jboss -c set
following happens:
  1. Behaviour of "-" character is very mysterious ;) (see man su for cryptic "explanation").
  2. Bash is launched with "-c set" as argument.
  3. When bash encounters "-c" it enters NON-INTERACTIVE mode and reads commands from supplied string (in this case single command "set").
    Bash doesn't read ~/.bashrc and ~/.bash_profile files when in non-interactive mode. Check man bash - section INVOCATION.
It seems the most dependable way to do what you want is

Code: Select all

$ su jboss --login -c set
as it launches bash with --login option - bash enters non-interactive LOGIN mode and reads ~/.bash_profile.
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Fri May 19, 2006 3:14 pm

I agree with taciturnus about the behaviour of - being mysterious :)

However, if you just want so set variables in the execution environment of the command, you can do it like this:

Code: Select all

su jboss -c 'export FOO=bar; <your command>'
Top
taciturnus
n00b
n00b
User avatar
Posts: 36
Joined: Tue Apr 05, 2005 6:43 am

  • Quote

Post by taciturnus » Fri May 19, 2006 3:30 pm

Please andreaske truncate or manually wrap extremely long lines in your CODE sections to make thread more readable ;).
Thanks.
Top
andreaske
n00b
n00b
Posts: 11
Joined: Wed Jan 11, 2006 10:44 am
Location: cologne/germany

[SOLVED] JAVA_HOME definition with su -

  • Quote

Post by andreaske » Fri May 19, 2006 7:30 pm

Thank you for you help. I used:

Code: Select all

su jboss --login -c set
and it works fine.
Last edited by andreaske on Mon May 22, 2006 9:17 am, edited 1 time in total.
Top
taciturnus
n00b
n00b
User avatar
Posts: 36
Joined: Tue Apr 05, 2005 6:43 am

  • Quote

Post by taciturnus » Fri May 19, 2006 7:58 pm

Please add [SOLVED] to post subject ;)
Or change it to something more suitable like "Environment variables and su -"
Top
Post Reply

6 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic