<?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: Setting Environment variable in UNIX Shell in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071170#M94944</link>
    <description>Hi Vikram&lt;BR /&gt;in perl script this is the right environment variable setting:&lt;BR /&gt;&lt;BR /&gt;$ENV{NAME}="ernesto";&lt;BR /&gt;&lt;BR /&gt;Best regards.&lt;BR /&gt;Ernesto</description>
    <pubDate>Thu, 27 Sep 2007 07:48:29 GMT</pubDate>
    <dc:creator>Ernesto Cappello</dc:creator>
    <dc:date>2007-09-27T07:48:29Z</dc:date>
    <item>
      <title>Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071167#M94941</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt; I want to set some environment variable through PERL script.&lt;BR /&gt;&lt;BR /&gt;  For this i am using the following code&lt;BR /&gt;        #!/usr/bin/perl&lt;BR /&gt;        `export HAI=hai`;&lt;BR /&gt;         $ENV{"HELLO"}="Hello"; &lt;BR /&gt;&lt;BR /&gt;       Now if i execute the script and do echo $HAI and echo $HELLO in the command prompt, it is not displaying anything.&lt;BR /&gt;&lt;BR /&gt;  Please correct me if i am wrong any where.&lt;BR /&gt;&lt;BR /&gt;thanks in advance&lt;BR /&gt;Vikram   &lt;BR /&gt;</description>
      <pubDate>Thu, 27 Sep 2007 05:27:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071167#M94941</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-09-27T05:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071168#M94942</link>
      <description>&lt;A href="http://www.injunea.demon.co.uk/pages/page207.htm" target="_blank"&gt;http://www.injunea.demon.co.uk/pages/page207.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://developer.apple.com/technotes/tn2002/tn2065.html" target="_blank"&gt;http://developer.apple.com/technotes/tn2002/tn2065.html&lt;/A&gt;</description>
      <pubDate>Thu, 27 Sep 2007 05:31:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071168#M94942</guid>
      <dc:creator>AwadheshPandey</dc:creator>
      <dc:date>2007-09-27T05:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071169#M94943</link>
      <description>I'm not sure wading through Awadhesh's links would find it easily.&lt;BR /&gt;&lt;BR /&gt;But the simple reason is that a child process can't change the environment of the parent.&lt;BR /&gt;&lt;BR /&gt;Several tricks a shell can do is to source a file, really same process.  Or return a string and the calling shell just does an eval on it:&lt;BR /&gt;$ eval $(echo export foo=bar)&lt;BR /&gt;$ env | fgrep foo&lt;BR /&gt;foo=bar</description>
      <pubDate>Thu, 27 Sep 2007 05:55:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071169#M94943</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-09-27T05:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071170#M94944</link>
      <description>Hi Vikram&lt;BR /&gt;in perl script this is the right environment variable setting:&lt;BR /&gt;&lt;BR /&gt;$ENV{NAME}="ernesto";&lt;BR /&gt;&lt;BR /&gt;Best regards.&lt;BR /&gt;Ernesto</description>
      <pubDate>Thu, 27 Sep 2007 07:48:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071170#M94944</guid>
      <dc:creator>Ernesto Cappello</dc:creator>
      <dc:date>2007-09-27T07:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071171#M94945</link>
      <description>You start a new child process (perl) and then you change the environment of that process.&lt;BR /&gt;But environment changes are not available in the parent process.&lt;BR /&gt;&lt;BR /&gt;In shell you would source the script instead of executing it to get the desired behavior.&lt;BR /&gt;But this is not possible with a perl script.&lt;BR /&gt;&lt;BR /&gt;My 2 cents,&lt;BR /&gt;Armin&lt;BR /&gt;&lt;BR /&gt;PS: Assign points if you find answers useful!&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 04:23:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071171#M94945</guid>
      <dc:creator>Armin Kunaschik</dc:creator>
      <dc:date>2007-09-28T04:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071172#M94946</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;like the other posters stated: There is no direct way to move the environment of child to the parent.&lt;BR /&gt;If the setup of an environment is the only task of your script, you'll have to generate code, which the parent can execute.&lt;BR /&gt;Example for Posix-Shell:&lt;BR /&gt;&lt;BR /&gt;cat myenv.pl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;$\ = "\n";&lt;BR /&gt;print "export HAI=hello;";&lt;BR /&gt;print "export HELP=man;";&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;In the shell, call&lt;BR /&gt;eval $(myenv.pl)&lt;BR /&gt;print $HAI&lt;BR /&gt;&lt;BR /&gt;This will lead to output 'hello'.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 28 Sep 2007 05:25:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071172#M94946</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-09-28T05:25:32Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071173#M94947</link>
      <description>&lt;!--!*#--&gt;Hi Vikram,&lt;BR /&gt;&lt;BR /&gt;can only access the environment of a parent in a child process but not the other way round.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;$ perl -e '$ENV{GOSSIP}='BlaBla';printf"GOSSIP in  in %s: $ENV{GOSSIP}\n",fork?"parent $$":"child $$"'                                   &lt;BR /&gt;GOSSIP in parent 19755: BlaBla&lt;BR /&gt;GOSSIP in child 19756: BlaBla&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also note, simple key hash definition of the package global hash %ENV is all that is required in Perl to set the environment.&lt;BR /&gt;No need for backticks, which would anyway only set the environment for the forked child subprocess via its shell.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 05:36:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071173#M94947</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2007-09-28T05:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071174#M94948</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;        thank you very much for the replys. I have tried all the options but i am not able to set the environment variable,&lt;BR /&gt;    I understand it is not possible directly but is there any way from which i can achieve this.&lt;BR /&gt;&lt;BR /&gt;        Please suggest some way &lt;BR /&gt;&lt;BR /&gt;thanks and regards&lt;BR /&gt;VikraM</description>
      <pubDate>Fri, 28 Sep 2007 07:11:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071174#M94948</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-09-28T07:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071175#M94949</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I don't think, you really tried my example.&lt;BR /&gt;What was the output of&lt;BR /&gt;myenv.pl&lt;BR /&gt;&lt;BR /&gt;and then, was there any output when calling&lt;BR /&gt;eval $(myenv.pl)&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 28 Sep 2007 07:32:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071175#M94949</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-09-28T07:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071176#M94950</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;either you set the environment you need in the script where you need it or you define it in the start file of your shell.&lt;BR /&gt;For an user it's for example .profile for sh-shell and .cshrc for c-shell.&lt;BR /&gt;&lt;BR /&gt;Volkmar&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:38:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071176#M94950</guid>
      <dc:creator>V. Nyga</dc:creator>
      <dc:date>2007-09-28T07:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071177#M94951</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You can't get where you want directly as stated by many.  Another variation is to let your Perl script do whatever its objective is and create a file of the variables you want exported.  Then, at will, source (read) them into your current environment:&lt;BR /&gt;&lt;BR /&gt;# cat some.pl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;open( FH, "&amp;gt;", 'env.sh' ) or die;&lt;BR /&gt;print FH "HAI=hai\n";&lt;BR /&gt;print FH "HELLO=Hello\n";&lt;BR /&gt;&lt;BR /&gt;# ./some.pl&lt;BR /&gt;# . ./env.sh&lt;BR /&gt;echo ${HELLO}&lt;BR /&gt;Hello&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:47:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071177#M94951</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-28T07:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071178#M94952</link>
      <description>Hi JRF,&lt;BR /&gt;&lt;BR /&gt;   Yes i am also thinking of the same solution but only thing is i have planned to execute both the perl script and the generated shell script through another shell script.&lt;BR /&gt;&lt;BR /&gt;    Ex -&lt;BR /&gt;       !#/usr/bin/sh&lt;BR /&gt;        Some.pl&lt;BR /&gt;        chmod +x Env.sh &lt;BR /&gt;       source Env.sh&lt;BR /&gt;&lt;BR /&gt;     Where Env.sh is the generated file.&lt;BR /&gt;&lt;BR /&gt;       But if i do this i m getting the error source not found. Can you correct me if i am executing the shell script in wrong way please&lt;BR /&gt;thanks and regards&lt;BR /&gt;Vikram&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 07:57:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071178#M94952</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-09-28T07:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071179#M94953</link>
      <description>Hi (again) Vikram:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Yes i am also thinking of the same solution but only thing is i have planned to execute both the perl script and the generated shell script through another shell script.&lt;BR /&gt;&lt;BR /&gt;Fine, do something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo "running Perl next"&lt;BR /&gt;/home/vikram/perlthing #...outputs /home/vikram/env.sh&lt;BR /&gt;. /home/vikram/env.sh #...sources env.sh&lt;BR /&gt;echo "Now I can say ${HELLO}"&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Sep 2007 08:07:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071179#M94953</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-28T08:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071180#M94954</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    thank you all for the reply &lt;BR /&gt;&lt;BR /&gt;        I got the solution i.e,&lt;BR /&gt;&lt;BR /&gt;        execute the perl script through a shell script and write all the env variables into a file and execute this file as source i.e. , by . ./Env.sh and also execute the shell script that is executing the Perl script also as source .</description>
      <pubDate>Fri, 28 Sep 2007 08:12:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071180#M94954</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-09-28T08:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071181#M94955</link>
      <description>Hi (again) Vikram:&lt;BR /&gt;&lt;BR /&gt;By the way:&lt;BR /&gt;&lt;BR /&gt;You don't need to turn the executable bit on to source (read) a file as you showed in your example, above.&lt;BR /&gt;&lt;BR /&gt;Also: If you are using the HP-UX POSIX shell (the standard one) you need to use the dot-space-filename notation to source.  If you are using the 'bash' shell, your 'source' notation is fine.  NEVER change 'root's shell from '/sbin/sh' to anything else or risk having a system that will not startup after a boot!!!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 28 Sep 2007 08:17:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071181#M94955</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-09-28T08:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Setting Environment variable in UNIX Shell</title>
      <link>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071182#M94956</link>
      <description>Thank you all for your valuable suggestions&lt;BR /&gt;Solution i found i have already shown in my reply&lt;BR /&gt;thanks and regards&lt;BR /&gt;Vikram</description>
      <pubDate>Sat, 29 Sep 2007 01:13:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/setting-environment-variable-in-unix-shell/m-p/5071182#M94956</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2007-09-29T01:13:08Z</dc:date>
    </item>
  </channel>
</rss>

