You are not logged in.
In my Staden package certain environment settings need to be set before and after using the staden programs.
I've tried to do this from a bash script but could not get the settings to be used in the xterm the scripts are started from, so the user needs to source them manually with
. /etc/staden/staden-start and . /etc/staden/staden-stop (see below for the content of the files)
Can someone guide me how to achieve this from a script ?
/etc/staden/staden-start
# emacs: -*- shell-script -*- mode
# Note this file is sourced into the user session
# save originals
SAVED_TCL_LIBRARY=$TCL_LIBRARY
SAVED_TK_LIBRARY=$TK_LIBRARY
SAVED_PATH=$PATH
test -n "$MANPATH" && export SAVED_MANPATH=$MANPATH
test -n "$LD_LIBRARY_PATH" && export SAVED_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
export STADENROOT=/opt/staden
. ${STADENROOT}/staden.profile
echo "staden environment activated;"
echo "The staden environment is only valid in this terminal session;"
echo "use stadenstop or end session to deactivate the staden environment"
/etc/staden/staden-stop
# emacs: -*- shell-script -*- mode
# Note this file is sourced into the user session
export STADENROOT=
export STADENROOT_1_7=
export MACHINE=
export STADLIB=
export STADBIN=
export STADTABL=
# put back original variables, if non-empty
test -n "$SAVED_TCL_LIBRARY" && export TCL_LIBARY=$SAVED_TCL_LIBRARY && export SAVED_TCL_LIBRARY=
test -n "$SAVED_TK_LIBRARY" && export TK_LIBARY=$SAVED_TK_LIBRARY && export SAVED_TK_LIBRARY=
test -n "$SAVED_PATH" && export PATH=$SAVED_PATH && export SAVED_PATH=
test -n "$SAVED_MANPATH" && export MANPATH="$SAVED_MANPATH" && export SAVED_MANPATH=
if test -n "$SAVED_LD_LIBRARY_PATH"
then
export LD_LIBRARY_PATH="$SAVED_LD_LIBRARY_PATH"
export SAVED_LD_LIBRARY_PATH=
else
export LD_LIBRARY_PATH=
fi
echo "staden environment deactivated."
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
if you want a script to set up those variables, they'll all need an 'export' - otherwise the variable values will not pass on to child processes.
Offline
And if you're just _running_ the script in xterm, there's no way to "up export" variables to the parent (Xterm in this case).
You can however source the script into Xterm though, do "source /script/wherever"
Jams
Offline
And if you're just _running_ the script in xterm, there's no way to "up export" variables to the parent (Xterm in this case).
That's the answer i was afraid of and it's consistent with my own findings.
Sourcing manually is the way it works now.
Could a system-wide alias solve this and where should i install them ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
For system wide, /etc/profile.d/ -- everything in there gets sourced.
For your own user, source it in ~/.bashrc or whatever shell you use.
Jams
Offline