Jesus Arocho wrote:
>Hello:
>
>I am running Mandrake 8.2. Yesterday I noticed that my scripts were not
>running properly. They fail to set env variables to new values using the
>export command. I do get results from echo statements. Any ideas?
>
>
>------------------------------------------------------------------------
>
>Want to buy your Pack or Services from MandrakeSoft?
>Go to http://www.mandrakestore.com
>
Well, it would be easier if you supplied the script in question, but
let's see what happens when you C&P this one to an exxecutable file and
call it.
#!/bin/sh
export ONETIME=1
export TEATIME=2
export THREETIME="three"
export -p
echo $ONETIME
echo ${TEATIME} TEATIME
echo ${THREETIME}
As usual, the hashbang had better be the first two characters in the
script file.
Here is my output for it.
[tester@v5 tester]$ emacs test.sh
[tester@v5 tester]$ ./test.sh
export BROWSER="kfmclient openProfile webbrowsing"
export COLORTERM=""
export DISPLAY=":0.0"
export GTK_RC_FILES="/etc/gtk/gtkrc:/home/tester/.gtkrc"
export HELP_BROWSER="kfmclient openProfile webbrowsing"
export HISTCONTROL="ignoredups"
export HISTSIZE="1000"
export HOME="/home/tester"
export HOSTNAME="v5.civileme.net"
export HOSTTYPE="i586"
export INPUTRC="/etc/inputrc"
export KDE_MULTIHEAD="false"
export LANG="en_US"
export LANGUAGE="en_US:en"
export LC_COLLATE="en_US"
export LC_CTYPE="en_US"
export LC_MESSAGES="en_US"
export LC_MONETARY="en_US"
export LC_NUMERIC="en_US"
export LC_TIME="en_US"
export LESS="-MM"
export LESSKEY="/etc/.less"
export LESSOPEN="|/usr/bin/lesspipe.sh %s"
export LOGNAME="tester"
export
LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.tbz2=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lha=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:*.tiff=01;35:"
export MACHTYPE="i586-mandrake-linux-gnu"
export MAIL="/var/spool/mail/tester"
export NLSPATH="/usr/share/locale/%l/%N"
export ONETIME="1"
export OSTYPE="linux-gnu"
export
PATH="/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/home/tester/bin"
export PWD="/home/tester"
export QT_XFT="0"
export SECURE_LEVEL="2"
export SESSION_MANAGER="local/v5.civileme.net:/tmp/.ICE-unix/2595"
export SHELL="/bin/bash"
export SHLVL="5"
export TEATIME="2"
export TERM="xterm"
export THREETIME="three"
export USER="tester"
export XAUTHORITY="/home/tester/.Xauthority"
1
2 TEATIME
three
NOW ONCE THE PROCESS COMPLETES
[tester@v5 tester]$ echo $THREETIME
[tester@v5 tester]$
our exported variables are unset, as it should be.
If you get similar output, all is well. What will never happen is that
the exported variables get back to a calling routine They only get
passed to called routines. You need to be a little more clever to pass
them back (see functions), or you need to evaluate the ENV variable and
append your exports to that file, then do an exec to terminate the
current shell process and call the oiginal caller with a new ENV.
Civileme
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com