<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div><span>Dennis, </span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><span>Yes, it starts with </span><span style="font-size: 10pt;">#!/bin/bash</span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color:
transparent; font-style: normal;"><span>I didn't know it was possible to run a Bash script with out it ... interesting ... as the shell is Bash, I'll guess it could be done. </span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="font-size: 14px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; background-color: transparent; font-style: normal;"><br><blockquote style="border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: 'Courier New', courier, monaco, monospace,
sans-serif; font-size: 10pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr" style="color: rgb(0, 0, 0);"> <hr size="1"> <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> "dennisjperkins@comcast.net" <dennisjperkins@comcast.net><br> <b><span style="font-weight: bold;">To:</span></b> Mark G. Harvey <markgharvey@yahoo.com>; CLUE's mailing list <clue@cluedenver.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, June 24, 2013 2:21 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [clue] env variables<br> </font> </div> <div class="y_msg_container"><br><div id="yiv6851245116"><style type="text/css">#yiv6851245116 p {margin:0;}</style><div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;"><span>I'm guessing your script began with #!/bin/bash. That spawns a new process with its own
environment inherited from th parent. JAVA_HOME and PATH were set and exported in your script, so those values are set in your script's environment (and for any programs that it called). It does not set values in the parent environment. Try running it without #!/bin/bash. I think that will run the script in the same environment. Note that this means that your script can only be called from bash.<br><br><span style="color: rgb(0, 0, 255);">... great idea ! Yes, I do want to set JAVA_HOME & PATH in the current root shell </span></span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span><span style="color: rgb(0, 0, 255);"><br></span></span></div><div style="font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span style="color: rgb(0, 0, 0);"><span style="color: rgb(0, 0, 255);">I'll give it a go. Just might be
that simple a fix. </span><br><br>I have a few comments on the scripts.<br><br>1. Why the sleep statements? They don't appear to do anything useful. </span><span style="color: rgb(0, 0, 255);">... The sleep statements are there so I can read what is happening on the screen as the script is processed. </span><br><br>2. You don't need to use touch to create the file. .... <span style="color: rgb(0, 0, 255);">Ok, just a different method that I'm used to.</span> <br><br>3. You probably want to use > to write the first line to /etc/profile.d/00_jdk.sh. If the file already exists, you're appending your string. Using > will erase the file if it exists and write the string to an empty file. <span style="color: rgb(0, 0, 255);">Good idea ... I'll drop touch & use a single > to create a fresh file in /etc/profile.d/ </span><br><br> 4. You could use a HERE doc statement for all of
the echoes you used to create 00_jdk.sh.<span style="font-size: 12pt; background-color: transparent;"> <span style="color: rgb(0, 0, 255);">... I was attempting to avoid having to upload a small file when I could just use simple commands to create it. I'll have to check out the "heredoc" command. </span></span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span style="color: rgb(0, 0, 255);"><br></span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span style="color: rgb(0, 0, 255);">... Thanks for the feedback !!</span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span style="color: rgb(0, 0, 255);"><br></span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><span
style="color: rgb(0, 0, 255);"><br></span></div><div style="color: rgb(0, 0, 0); font-family: Arial; font-size: 12pt;" class="yui_3_7_2_32_1372097030457_70"><br><hr id="yiv6851245116zwchr"><b>From: </b>"Mark G. Harvey" <markgharvey@yahoo.com><br><b>To: </b>"CLUEmessage CLUE" <clue@cluedenver.org><br><b>Sent: </b>Monday, June 24, 2013 1:54:14 PM<br><b>Subject: </b>[clue] env variables<br><br><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 10pt;"><div>CLUE experts, </div><div><br>This puzzle is likely simple for you folks, but it has me stumped. I've done considerable digging but have found mixed advice. <br><br>I've created a script to download from a local repo via wget an rpm to install JDK ... no problem there. <br><br>Here's the part I can't get right ... setting the variables so I can run scripts to install Tomcat
... Any attempt will bomb if it can't find /usr/java/jdk1.7.0_21/bin <br><br><br># set JAVA_HOME variable ... tried in vain<br>echo "setting JAVA_HOME variable variable for the session" <br>JAVA_HOME=/usr/java/jdk1.7.0_21<br># export JAVA_HOME variable ... tried in vain<br>echo "exporting JAVA_HOME variable variable for the session" <br>export JAVA_HOME=/usr/java/jdk1.7.0_21<br>echo
"JAVA_HOME variable: $JAVA_HOME"<br><br># set PATH variable for the session ... tried in vain<br>echo "setting PATH variable for the session" <br>PATH=$PATH:/usr/java/jdk1.7.0_21/bin<br># export PATH variable for the session<br>echo "exporting PATH variable for the subsequent sessions & processes" <br>export PATH=$PATH:/usr/java/jdk1.7.0_21/bin<br>echo "show PATH variable: $PATH"<br><br>sleep 3 # wait<br><br># create script to set JAVA_HOME & PATH variables in /etc/profile.d/00_jdk.sh script for all accounts<br># use echo command with single quotes to write the literal statement to the script<br>touch /etc/profile.d/00_jdk.sh<br>echo '#!/bin/bash' >> /etc/profile.d/00_jdk.sh<br>echo '# set JAVA_HOME in /etc/profile.d/00_jdk.sh script for all accounts' >> /etc/profile.d/00_jdk.sh<br>echo 'JAVA_HOME=/usr/java/jdk1.7.0_21' >> /etc/profile.d/00_jdk.sh<br>echo '# set PATH in /etc/profile.d/00_jdk.sh
script for all accounts' >> /etc/profile.d/00_jdk.sh<br>echo 'PATH=$PATH:/usr/java/jdk1.7.0_21/bin' >> /etc/profile.d/00_jdk.sh <br><br>sleep 3 # wait<br><br>echo "review contents of /etc/profile.d/00_jdk.sh"<br>cat /etc/profile.d/00_jdk.sh<br><br><br>... results of install ... added some blank lines for readability ...<br><br>[root@87148-mondev01 ~]# ./DEV_install_jdk1.7-1.0.0.sh <br>installation: Oracle/Sun jdk 1.7 64-bit<br>remount /tmp with execute privledge<br>changed to /tmp<br>Pulling package from Artifactory Repo Management Server<br>--2013-06-24 13:24:38-- <a rel="nofollow" href="">https://<RepoHost>/artifactory/simple/ext-release-local/oracle/jdk/7u21-linux/jdk-7u21-linux-x64.rpm</a><br>Resolving <RepoHost>... 10.33.44.10<br>Connecting to <RepoHost>|10.33.44.10|:443...
connected.<br><br>HTTP request sent, awaiting response... 200 OK<br><br>Length: 85388149 (81M) [application/x-rpm]<br>Saving to: “jdk-7u21-linux-x64.rpm”<br><br>100%[=======================================================================================================================================>] 85,388,149 52.7M/s in 1.5s <br><br>2013-06-24 13:24:40 (52.7 MB/s) - “jdk-7u21-linux-x64.rpm” saved [85388149/85388149]<br><br>jdk downloaded<br>check /tmp/ contents for jdk<br>-rw-r--r--. 1 root root 85388149 Jun 6 16:46 jdk-7u21-linux-x64.rpm<br>install jdk rpm<br>Preparing... ########################################### [100%]<br>package jdk-2000:1.7.0_21-fcs.x86_64 is already installed ........ due to subsequent running of this script<br>install jdk complete<br><br>setting JAVA_HOME variable variable for the session<br>exporting
JAVA_HOME variable variable for the session<br><br>... when tested in the script, the correct answer shows up ... <br><br>JAVA_HOME variable: /usr/java/jdk1.7.0_21 <br><br>setting PATH variable for the session<br>exporting PATH variable for the subsequent sessions & processes<br><br>... when tested in the script, the correct answer shows up ... <br><br><br>show PATH variable: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_21/bin:/usr/java/jdk1.7.0_21/bin<br><br>review contents of /etc/profile.d/00_jdk.sh<br>#!/bin/bash<br># set JAVA_HOME in /etc/profile.d/00_jdk.sh script for all accounts<br>JAVA_HOME=/usr/java/jdk1.7.0_21<br># set PATH in /etc/profile.d/00_jdk.sh script for all accounts<br>PATH=$PATH:/usr/java/jdk1.7.0_21/bin<br>remount /tmp removing execute privledge<br>finished<br><br><br>... after script runs, when tested from CLI, variables not not correct
... <br><br>[root@87148-mondev01 ~]# echo $JAVA_HOME<br><br>[root@87148-mondev01 ~]# echo $PATH<br>/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin<br><br><br><br>[root@87148-mondev01 ~]# exit<br>logout<br><br>[vwadmin@87148-mondev01 ~]$ su -<br>Password: <br><br><br>... now the variable additions show up ... they come from the /etc/profile.d/00_jdk.sh script created as part of the JDK download & install ... <br><br>[root@87148-mondev01 ~]# echo $PATH<br>/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.7.0_21/bin:/root/bin<br><br>[root@87148-mondev01 ~]# echo $JAVA_HOME<br>/usr/java/jdk1.7.0_21<br><br><br><br>... How can I get the variables to be available for the current root session & usable for subsequent installations? Trying to avoid the logout / login ... <br><br><br><br>Thanks for your help.
<br></div></div><br>_______________________________________________<br>clue mailing list: clue@cluedenver.org<br>For information, account preferences, or to unsubscribe see:<br>http://cluedenver.org/mailman/listinfo/clue</div></div></div><br><br></div> </div> </div> </blockquote></div> </div></body></html>