<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Environment variables in shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020355#M764348</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;As suggested by James u have to run env.sh in &lt;BR /&gt;the same shell, if u r using&lt;BR /&gt;&lt;BR /&gt;sh env.sh&lt;BR /&gt;&lt;BR /&gt;then a child shell process is created,&lt;BR /&gt;the exported variables in env.sh will be &lt;BR /&gt;available to processes which r child of shell&lt;BR /&gt;running env.sh, hence after&lt;BR /&gt;&lt;BR /&gt;sh env.sh&lt;BR /&gt;&lt;BR /&gt;these variables r distroyed, to prevent this&lt;BR /&gt;and make ur exported variables in same shell&lt;BR /&gt;use&lt;BR /&gt;&lt;BR /&gt;. env.sh&lt;BR /&gt;&lt;BR /&gt;using . (dot) will tell shell to run process in&lt;BR /&gt;current shell only, thus all the shell&lt;BR /&gt;variables in env.sh will be available in ur&lt;BR /&gt;2nd script dbprod.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Santosh</description>
    <pubDate>Wed, 27 Dec 2006 01:18:31 GMT</pubDate>
    <dc:creator>SANTOSH S. MHASKAR</dc:creator>
    <dc:date>2006-12-27T01:18:31Z</dc:date>
    <item>
      <title>Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020352#M764345</link>
      <description>I have one script which has some variables set and I need to use them outside the script, i.e., I will call a standard script through several other scripts and I have to re-use the main one to avoid errors.&lt;BR /&gt;&lt;BR /&gt;Is it possible in HP-UX 11.&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;1st script ( env.sh )&lt;BR /&gt;DBCONNECTION=/usr/local/etc/param.pf; export DBCONNECTION&lt;BR /&gt;&lt;BR /&gt;2nd script ( dbprod.sh )&lt;BR /&gt;sh env.sh&lt;BR /&gt;mpro -pf $DBCONNECTION&lt;BR /&gt;&lt;BR /&gt;When I call the 2nd script the environment variables as empty and the application doens't start.&lt;BR /&gt;&lt;BR /&gt;Please, help me</description>
      <pubDate>Tue, 26 Dec 2006 20:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020352#M764345</guid>
      <dc:creator>ZezinhoBD</dc:creator>
      <dc:date>2006-12-26T20:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020353#M764346</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You need to 'source' or read your variables.  For example:&lt;BR /&gt;&lt;BR /&gt;# cat ./sh1&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;DBCONNECTION=/usr/local/etc/param.pf&lt;BR /&gt;&lt;BR /&gt;# cat ./sh2&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;. ./sh1&lt;BR /&gt;mpro -pf ${DBCONNECTION}&lt;BR /&gt;&lt;BR /&gt;That is, you use a dot (".") operator followed by a blank (space), followed by the name of the file to be 'source'd (read, or included).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 26 Dec 2006 21:12:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020353#M764346</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-12-26T21:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020354#M764347</link>
      <description>And the reason is that when you "call a&lt;BR /&gt;standard script", you're actually running&lt;BR /&gt;that shell script in its own process, and&lt;BR /&gt;that shell process has its own environment.&lt;BR /&gt;Setting an environment variable in that&lt;BR /&gt;shell's environment does nothing to the&lt;BR /&gt;environment of the original shell's process.&lt;BR /&gt;&lt;BR /&gt;Using the "." command causes the original&lt;BR /&gt;shell to read and execute the second script's&lt;BR /&gt;commands, so those commands now affect the&lt;BR /&gt;environment of the original shell process&lt;BR /&gt;(which is the only process in this case).&lt;BR /&gt;&lt;BR /&gt;Note, too, that when using ".", the second&lt;BR /&gt;"script" file does not need to be executable,&lt;BR /&gt;and it does not need a "#!shell_path" on its&lt;BR /&gt;first line.  (That's because it's not really&lt;BR /&gt;being used as a shell script, only as a kind&lt;BR /&gt;of data file for the first shell script.)&lt;BR /&gt;&lt;BR /&gt;Of course, if that second file _is_&lt;BR /&gt;executable then you can also use it as a&lt;BR /&gt;shell script, and then you'll probably want&lt;BR /&gt;to include a "#!shell_path" in it.</description>
      <pubDate>Tue, 26 Dec 2006 22:59:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020354#M764347</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2006-12-26T22:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020355#M764348</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;As suggested by James u have to run env.sh in &lt;BR /&gt;the same shell, if u r using&lt;BR /&gt;&lt;BR /&gt;sh env.sh&lt;BR /&gt;&lt;BR /&gt;then a child shell process is created,&lt;BR /&gt;the exported variables in env.sh will be &lt;BR /&gt;available to processes which r child of shell&lt;BR /&gt;running env.sh, hence after&lt;BR /&gt;&lt;BR /&gt;sh env.sh&lt;BR /&gt;&lt;BR /&gt;these variables r distroyed, to prevent this&lt;BR /&gt;and make ur exported variables in same shell&lt;BR /&gt;use&lt;BR /&gt;&lt;BR /&gt;. env.sh&lt;BR /&gt;&lt;BR /&gt;using . (dot) will tell shell to run process in&lt;BR /&gt;current shell only, thus all the shell&lt;BR /&gt;variables in env.sh will be available in ur&lt;BR /&gt;2nd script dbprod.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-Santosh</description>
      <pubDate>Wed, 27 Dec 2006 01:18:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020355#M764348</guid>
      <dc:creator>SANTOSH S. MHASKAR</dc:creator>
      <dc:date>2006-12-27T01:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020356#M764349</link>
      <description>Hi,&lt;BR /&gt;export the varaiable in the first script. execute it as '.' script, and you will be able to see the variable in teh other script:&lt;BR /&gt;1:&lt;BR /&gt;/&amp;gt; cat test1&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;export A="I'm A"&lt;BR /&gt;#eof&lt;BR /&gt;&lt;BR /&gt;2:/&amp;gt; cat test2&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;. test1&lt;BR /&gt;echo "I'm test2"&lt;BR /&gt;echo $A&lt;BR /&gt;#eof&lt;BR /&gt;&lt;BR /&gt;3:&amp;gt; test2&lt;BR /&gt;I'm test2&lt;BR /&gt;I'm A&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 02 Jan 2007 04:06:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020356#M764349</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-01-02T04:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020357#M764350</link>
      <description>Use source command if you are using C shell.</description>
      <pubDate>Tue, 02 Jan 2007 04:40:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020357#M764350</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2007-01-02T04:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Environment variables in shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020358#M764351</link>
      <description>The answer from James R Fergusson solve my problem.&lt;BR /&gt;&lt;BR /&gt;Tks.</description>
      <pubDate>Tue, 02 Jan 2007 05:25:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/environment-variables-in-shell-script/m-p/5020358#M764351</guid>
      <dc:creator>ZezinhoBD</dc:creator>
      <dc:date>2007-01-02T05:25:46Z</dc:date>
    </item>
  </channel>
</rss>

