<?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: export variables to outside of a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810025#M100071</link>
    <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;Source (read) the script with the variable(s) you need.  For example:&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/A&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fruit=apple&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/B&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fruit=apple&lt;BR /&gt;&lt;BR /&gt;# /tmp/B&lt;BR /&gt;I want a(n) apple&lt;BR /&gt;&lt;BR /&gt;...Note the dot, followed by a space, followed by the script to be sourced (read).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 21 Jun 2006 13:54:39 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2006-06-21T13:54:39Z</dc:date>
    <item>
      <title>export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810024#M100070</link>
      <description>I have a script that defines fruit and I want other scripts to see it.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;export fruit=orange&lt;BR /&gt;&lt;BR /&gt;but, after running the script, other scripts still can not see it :-(&lt;BR /&gt;&lt;BR /&gt;how do I make it happen?&lt;BR /&gt;&lt;BR /&gt;thank you</description>
      <pubDate>Wed, 21 Jun 2006 13:49:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810024#M100070</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T13:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810025#M100071</link>
      <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;Source (read) the script with the variable(s) you need.  For example:&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/A&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fruit=apple&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/B&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fruit=apple&lt;BR /&gt;&lt;BR /&gt;# /tmp/B&lt;BR /&gt;I want a(n) apple&lt;BR /&gt;&lt;BR /&gt;...Note the dot, followed by a space, followed by the script to be sourced (read).&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 21 Jun 2006 13:54:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810025#M100071</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-21T13:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810026#M100072</link>
      <description>I am confused..&lt;BR /&gt;&lt;BR /&gt;you defined apple both in /tmp/A and /tmp/B......&lt;BR /&gt;&lt;BR /&gt;am I missing something..</description>
      <pubDate>Wed, 21 Jun 2006 14:00:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810026#M100072</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T14:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810027#M100073</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;No, you're not missing something, I am! :-))&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/A&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;fruit=apple&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/B&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;. /tmp/A&lt;BR /&gt;echo "I want a(n) ${fruit}"&lt;BR /&gt;&lt;BR /&gt;# /tmp/B&lt;BR /&gt;I want a(n) apple&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 14:03:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810027#M100073</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-21T14:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810028#M100074</link>
      <description>ah! &lt;BR /&gt;&lt;BR /&gt;so easy, but I made it too complicated!!&lt;BR /&gt;&lt;BR /&gt;thank you!!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 14:06:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810028#M100074</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T14:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810029#M100075</link>
      <description>hi;&lt;BR /&gt;&lt;BR /&gt;when you export a variable it's only be used by   current and it's child shells. if you export it within a script, it doesn't pass to parent shell. so you can't get the value.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 14:23:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810029#M100075</guid>
      <dc:creator>Kenan Erdey</dc:creator>
      <dc:date>2006-06-21T14:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810030#M100076</link>
      <description>Kenan Erdey said:&lt;BR /&gt;&amp;gt;when you export a variable it's only be used by current and its child shells.&lt;BR /&gt;&lt;BR /&gt;Right.  The only way to see it is to either source it as JRF said, or to return a string with the info.  Similar to:&lt;BR /&gt;   eval $(resize)</description>
      <pubDate>Wed, 21 Jun 2006 14:55:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810030#M100076</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-06-21T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810031#M100077</link>
      <description>you are right.....now, other scripts can not use it..&lt;BR /&gt;&lt;BR /&gt;what do you meant by "eval $(resize)"</description>
      <pubDate>Wed, 21 Jun 2006 19:07:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810031#M100077</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T19:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810032#M100078</link>
      <description>&amp;gt;what do you meant by "eval $(resize)"&lt;BR /&gt;&lt;BR /&gt;Basically resize (for X windows) wants to change the LINES and COLUMNS variables.  Since it can't export those values (it's an executable), it outputs to stdout:&lt;BR /&gt;$ resize&lt;BR /&gt;COLUMNS=80;&lt;BR /&gt;LINES=36;&lt;BR /&gt;export COLUMNS LINES;&lt;BR /&gt;&lt;BR /&gt;And then eval does the export, kind of like sourcing it, in the current shell.</description>
      <pubDate>Wed, 21 Jun 2006 19:44:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810032#M100078</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-06-21T19:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810033#M100079</link>
      <description>so, I have to export the variables again...hmmmm...&lt;BR /&gt;&lt;BR /&gt;go back to square 1....</description>
      <pubDate>Wed, 21 Jun 2006 19:47:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810033#M100079</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T19:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810034#M100080</link>
      <description>then, how do I export variables out of my scripts :-(&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 19:49:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810034#M100080</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T19:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810035#M100081</link>
      <description>&amp;gt;then, how do I export variables out of my scripts :-(&lt;BR /&gt;&lt;BR /&gt;Assuming your script doesn't have any other output, you would use:&lt;BR /&gt;&lt;BR /&gt;echo "export FOO=$FOO;"&lt;BR /&gt;echo "export BAR=$BAR;"&lt;BR /&gt;&lt;BR /&gt;Then the callers of your script would use:&lt;BR /&gt;   eval $(sub_script_that_wants_to_export)</description>
      <pubDate>Wed, 21 Jun 2006 19:57:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810035#M100081</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-06-21T19:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810036#M100082</link>
      <description>Hi (again) Gemini:&lt;BR /&gt;&lt;BR /&gt;Look at the manpages for 'resize'.  Dennis is pointing out that another way we can communicate between processes is to have a process return information by echoing (printing) a string:&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/C&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo $(resize)&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/D&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;VAR=$(/tmp/C)&lt;BR /&gt;echo "I was told ${VAR}"&lt;BR /&gt;&lt;BR /&gt;# /tmp/D&lt;BR /&gt;I was told COLUMNS=80; LINES=24; export COLUMNS LINES;&lt;BR /&gt;&lt;BR /&gt;...Now, using our FRUIT variable:&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/E&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;echo "export FRUIT=oranges"&lt;BR /&gt;&lt;BR /&gt;# cat /tmp/F&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;eval $(/tmp/E)&lt;BR /&gt;echo "I was offered some ${FRUIT}"&lt;BR /&gt;&lt;BR /&gt;# /tmp/F&lt;BR /&gt;I was offered some oranges&lt;BR /&gt;&lt;BR /&gt;The 'eval' essentially makes a two-pass sweep to allow parameter substitution for keywords and characters that would otherwise be unrecognized in the resulting commands.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 20:01:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810036#M100082</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-06-21T20:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810037#M100083</link>
      <description>thanks, the fruit example was clear. &lt;BR /&gt;&lt;BR /&gt;I got it now!!&lt;BR /&gt;&lt;BR /&gt;thank you very much!&lt;BR /&gt;&lt;BR /&gt;you guys are really good!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jun 2006 20:06:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810037#M100083</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-06-21T20:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810038#M100084</link>
      <description>It also helps to understand subshells. When you simply run a script with it's name, a new shell is started (a subshell) and your script is interpreted (run) in that shell. When the subshell reaches the end of the script, it terminates and all the changes disappear with the subshell.&lt;BR /&gt; &lt;BR /&gt;The term 'sourcing' is somewhat unique to Unix and describes the smallest shell command, namely the . (dot). What the dot accomplishes is to prevent a subshell from running, but instead, interprets the script in the current shell. So you 'source' your script and all the changes inside the script stay in the current shell. If your script exports any variables, they are available to other scripts (and programs). The env command shows all the variables which will pass to child processes (aka, the environment).</description>
      <pubDate>Wed, 21 Jun 2006 20:19:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810038#M100084</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-06-21T20:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: export variables to outside of a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810039#M100085</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;for this purpose I once made a script 'add2env'. In scripts, which need such a feature I call it in a way like that:&lt;BR /&gt;...&lt;BR /&gt;eval `add2env -B -d: LD_LIBRARY_PATH /path1 /path2`&lt;BR /&gt;&lt;BR /&gt;add2env is written in tcsh (the project requesting the programmed features wanted it that way ...) using builtin commands only - no external progs are used.&lt;BR /&gt;add2env takes care not to enter values in array-like variables twice.&lt;BR /&gt;&lt;BR /&gt;Containing some german words, the usage is understandable nevertheless, I think.&lt;BR /&gt;&lt;BR /&gt; usage: add2env [-d delimchar] ADD2THISVAR val1 ...&lt;BR /&gt; Optionen:&lt;BR /&gt; -B  Bourne/KornShell Stil&lt;BR /&gt; -C  Tcsh/CSH Stil (default)&lt;BR /&gt;&lt;BR /&gt; -D     Delete der Werte statt add&lt;BR /&gt; -l  lokale Variablen (statt Environment)&lt;BR /&gt; -d c  delimiter ist 'c' (default: ' ')&lt;BR /&gt; nur bei ADD:&lt;BR /&gt; -0     neue Werte vorne hinsetzen&lt;BR /&gt; -1     neue Werte an vorletzte Stelle hinsetzen&lt;BR /&gt; nur bei DELETE:&lt;BR /&gt; -u     unset der Variable, wenn leer&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Jun 2006 06:33:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/export-variables-to-outside-of-a-script/m-p/3810039#M100085</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-06-22T06:33:45Z</dc:date>
    </item>
  </channel>
</rss>

