<?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: Korn Shell Script not returning variables to parent in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181853#M322516</link>
    <description>Look men,&lt;BR /&gt;&lt;BR /&gt;     You are exporting variable, then also it will effected while the process is running, it gives the same value to all child proccess too. but it will not give the value after termination of the process to parent process.&lt;BR /&gt;&lt;BR /&gt;like ...&lt;BR /&gt;&lt;BR /&gt;#T="Test"        Declaring Variable&lt;BR /&gt;#export $T       Export in outer shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;#sh              Inner Shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;#T="Test1"       Modify Variable&lt;BR /&gt;#export $T       Export in inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#sh              Child inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#exit            Exit from Child inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#exit            Exit from Inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Piyush Mathiya&lt;BR /&gt;</description>
    <pubDate>Thu, 17 Apr 2008 12:17:50 GMT</pubDate>
    <dc:creator>piyush mathiya</dc:creator>
    <dc:date>2008-04-17T12:17:50Z</dc:date>
    <item>
      <title>Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181852#M322515</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm using a Korn shell on Hp-UX B.11.23&lt;BR /&gt;&lt;BR /&gt;My problem is that an interactive variable assignment runs fine e.g.&lt;BR /&gt;&lt;BR /&gt;# ORACLE_SID=Rencs&lt;BR /&gt;# export ORACLE_SID&lt;BR /&gt;# echo $ORACLE_SID&lt;BR /&gt;Rencs&lt;BR /&gt;&lt;BR /&gt;But, I am unsuccessful if I try to ksh this as a .sh file or run a symbolic link to this file.&lt;BR /&gt;&lt;BR /&gt;# cat .test.sh&lt;BR /&gt;ORACLE_SID=Rencs&lt;BR /&gt;export ORACLE_SID&lt;BR /&gt;echo $ORACLE_SID&lt;BR /&gt;&lt;BR /&gt;Now, run this file but set SID to something else first:&lt;BR /&gt;&lt;BR /&gt;# ORACLE_SID=diff&lt;BR /&gt;# echo $ORACLE_SID&lt;BR /&gt;diff&lt;BR /&gt;# ksh .test.sh&lt;BR /&gt;Rencs&lt;BR /&gt;# echo $ORACLE_SID&lt;BR /&gt;diff&lt;BR /&gt;&lt;BR /&gt;It looks like the called process does not pass the variable back to the parent?</description>
      <pubDate>Thu, 17 Apr 2008 12:05:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181852#M322515</guid>
      <dc:creator>Rory C. Lehane</dc:creator>
      <dc:date>2008-04-17T12:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181853#M322516</link>
      <description>Look men,&lt;BR /&gt;&lt;BR /&gt;     You are exporting variable, then also it will effected while the process is running, it gives the same value to all child proccess too. but it will not give the value after termination of the process to parent process.&lt;BR /&gt;&lt;BR /&gt;like ...&lt;BR /&gt;&lt;BR /&gt;#T="Test"        Declaring Variable&lt;BR /&gt;#export $T       Export in outer shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;#sh              Inner Shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;#T="Test1"       Modify Variable&lt;BR /&gt;#export $T       Export in inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#sh              Child inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#exit            Exit from Child inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test1&lt;BR /&gt;#exit            Exit from Inner shell&lt;BR /&gt;#echo $T         Print variable&lt;BR /&gt;Test&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Piyush Mathiya&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Apr 2008 12:17:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181853#M322516</guid>
      <dc:creator>piyush mathiya</dc:creator>
      <dc:date>2008-04-17T12:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181854#M322517</link>
      <description>&lt;!--!*#--&gt;if you want the variables to be in the environment of the parent process / shell, then you need to "source" the script that sets them. In the ksh, this is sometimes referred to as "dotting in" the script.  in your case, at the command line, run it as follows:&lt;BR /&gt;&lt;BR /&gt;. .test.sh&lt;BR /&gt;(Thats "dot space dot test.sh"&lt;BR /&gt;&lt;BR /&gt;Note the space between the two dots.  You can do the same thing within a script if you need the values set in ".test.sh" to be available to the parent / calling script</description>
      <pubDate>Thu, 17 Apr 2008 12:23:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181854#M322517</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2008-04-17T12:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181855#M322518</link>
      <description>&lt;!--!*#--&gt;&amp;gt; . .test.sh&lt;BR /&gt;&lt;BR /&gt;It's unusual to name a script (or script&lt;BR /&gt;fragment) dot-something, like ".test.sh".&lt;BR /&gt;Did you read somewhere about using&lt;BR /&gt;".   test.sh", and not see the space between&lt;BR /&gt;the dot (".") and the script (fragment) name&lt;BR /&gt;("test.sh")?&lt;BR /&gt;&lt;BR /&gt;(When people don't check the "Retain&lt;BR /&gt;format(spacing)" box in this forum, spaces&lt;BR /&gt;often become very hard to see.)</description>
      <pubDate>Thu, 17 Apr 2008 17:44:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181855#M322518</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-17T17:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181856#M322519</link>
      <description>&lt;!--!*#--&gt;the dot before the filename was to follow the same format as a .profile because this is a script that runs application specific logicals separate but similar to a ".profile".&lt;BR /&gt;&lt;BR /&gt;The problem remains though:&lt;BR /&gt;if I "ksh .test.sh" or ". ./.test.sh" interactively, the logical assignment works in that process, but if I call the script from another script - it will not return the logicals to the calling/parent process.&lt;BR /&gt;&lt;BR /&gt;The logic behind this is that I am trying to setup  symbolic links so that a user can login and then either type "test" or "live" which will then run the appropriate script to setup logicals (rather than having separate user accounts).</description>
      <pubDate>Fri, 18 Apr 2008 07:41:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181856#M322519</guid>
      <dc:creator>Rory C. Lehane</dc:creator>
      <dc:date>2008-04-18T07:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181857#M322520</link>
      <description>&amp;gt;It looks like the called process does not pass the variable back to the parent?&lt;BR /&gt;&lt;BR /&gt;This is correct.  As Piyush said, environment variables go from parent to child, not the other way.&lt;BR /&gt;&lt;BR /&gt;To go the other way you need to try one of these kludges:&lt;BR /&gt;1) Return a string from your script and eval it.&lt;BR /&gt;2) Return a file and source it.&lt;BR /&gt;3) Or source that script (OldSchool)&lt;BR /&gt;&lt;BR /&gt;See this thread:&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1077113" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1077113&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;The problem remains though: ... if I call the script from another script - it will not return the logicals to the calling/parent process.&lt;BR /&gt;&lt;BR /&gt;We told you why.  You have to implement one of these kludges.&lt;BR /&gt;&lt;BR /&gt;Or invert how your scripts work.</description>
      <pubDate>Fri, 18 Apr 2008 09:49:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181857#M322520</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-18T09:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Korn Shell Script not returning variables to parent</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181858#M322521</link>
      <description>&lt;!--!*#--&gt;&amp;gt; the dot before the filename was to follow&lt;BR /&gt;&amp;gt; the same format as a .profile because this&lt;BR /&gt;&amp;gt; is a script that runs application specific&lt;BR /&gt;&amp;gt; logicals separate but similar to a&lt;BR /&gt;&amp;gt; ".profile".&lt;BR /&gt;&lt;BR /&gt;Swell. So, you're hiding your script fragment&lt;BR /&gt;from a normal "ls" command.  Was that your&lt;BR /&gt;intention?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] but if I call the script from another&lt;BR /&gt;&amp;gt; script [...]&lt;BR /&gt;&lt;BR /&gt;You don't really "call" a script.  You can&lt;BR /&gt;run a script ("./script"), in its own&lt;BR /&gt;process, with its own environment, so it&lt;BR /&gt;can't set any of your variables, or you can&lt;BR /&gt;include a script fragment (".  ./script"), so&lt;BR /&gt;that its commands are executed in the&lt;BR /&gt;including ("calling"?) script's process, as&lt;BR /&gt;if the script fragment were actually in the&lt;BR /&gt;including script at that point, so its&lt;BR /&gt;variables are your variables.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...]then either type "test" or "live"&lt;BR /&gt;&amp;gt; which will then run the appropriate script&lt;BR /&gt;&amp;gt; to setup logicals [...]&lt;BR /&gt;&lt;BR /&gt;As explained, "run the script" is exactly&lt;BR /&gt;what you don't want.  What's wrong with&lt;BR /&gt;something like this:&lt;BR /&gt;&lt;BR /&gt;if &lt;CONDITION&gt; ; then&lt;BR /&gt;    .   ./test&lt;BR /&gt;else&lt;BR /&gt;    .   ./live&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;... so your main script would be including&lt;BR /&gt;the appropriate script fragment?&lt;/CONDITION&gt;</description>
      <pubDate>Fri, 18 Apr 2008 11:31:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-script-not-returning-variables-to-parent/m-p/4181858#M322521</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-04-18T11:31:42Z</dc:date>
    </item>
  </channel>
</rss>

