<?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: How does one set a variable variable? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886117#M935828</link>
    <description>Hi Seth&lt;BR /&gt;&lt;BR /&gt;Since you are treating DEP as a vraible too you would need to reset the same in case you need to change $MAIN , the other was would be to use a shell scirpt to attaint eh same which can have if with 2 conditons.In the shell it wont be possible as the youy are dealing with two variables , and to set that you would need 2 statements not one.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
    <pubDate>Tue, 21 Jan 2003 04:48:42 GMT</pubDate>
    <dc:creator>MANOJ SRIVASTAVA</dc:creator>
    <dc:date>2003-01-21T04:48:42Z</dc:date>
    <item>
      <title>How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886111#M935822</link>
      <description>Is there a way to have a value of a shell variable be dependent on that of another?&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;MAIN=Sad&lt;BR /&gt;DEP=$MAIN" times"&lt;BR /&gt;&lt;BR /&gt;echo $DEP would return "Sad times"&lt;BR /&gt;&lt;BR /&gt;But what I'm looking for is if I were to next enter:&lt;BR /&gt;&lt;BR /&gt;MAIN=Happy&lt;BR /&gt;echo $DEP would now return "Happy times"&lt;BR /&gt;&lt;BR /&gt;I realize the above code won't give me what I want, but can something to this effect be accomplished?  Any ideas?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Seth</description>
      <pubDate>Tue, 21 Jan 2003 00:12:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886111#M935822</guid>
      <dc:creator>Seth Parker</dc:creator>
      <dc:date>2003-01-21T00:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886112#M935823</link>
      <description>The above is possible, yes.&lt;BR /&gt;&lt;BR /&gt;In a script, something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;MAIN="Sad"&lt;BR /&gt;OTHER=" times"&lt;BR /&gt;&lt;BR /&gt;DEP=${MAIN}${OTHER}&lt;BR /&gt;&lt;BR /&gt;echo ${DEP}&lt;BR /&gt;&lt;BR /&gt;MAIN="Happy"&lt;BR /&gt;&lt;BR /&gt;DEP=${MAIN}${OTHER}&lt;BR /&gt;&lt;BR /&gt;echo ${DEP}</description>
      <pubDate>Tue, 21 Jan 2003 00:26:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886112#M935823</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-01-21T00:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886113#M935824</link>
      <description>Seth,&lt;BR /&gt;&lt;BR /&gt;It is very simple to do this.&lt;BR /&gt;&lt;BR /&gt;You just have to specify the parameter every time you want a value out of it. Only care you have to take is that you don't re-specify the variable value till you have got the result of the first one.&lt;BR /&gt;&lt;BR /&gt;The earlier post explains it nicely.&lt;BR /&gt;&lt;BR /&gt;-Anil</description>
      <pubDate>Tue, 21 Jan 2003 00:41:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886113#M935824</guid>
      <dc:creator>Anil C. Sedha</dc:creator>
      <dc:date>2003-01-21T00:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886114#M935825</link>
      <description>Ya as said its very simple. Just assign both values to variables and play with them.&lt;BR /&gt;like &lt;BR /&gt;MAIN=Sad&lt;BR /&gt;TIM=times&lt;BR /&gt;then&lt;BR /&gt;echo $MAIN $TIM (will give Sad times)&lt;BR /&gt;and then &lt;BR /&gt;MAIN=happy&lt;BR /&gt;&lt;BR /&gt;and echo $MAIN $TIM&lt;BR /&gt;would return happy times&lt;BR /&gt;&lt;BR /&gt;Just give a try&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;Rajeev</description>
      <pubDate>Tue, 21 Jan 2003 00:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886114#M935825</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2003-01-21T00:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886115#M935826</link>
      <description>I guess I should have expanded my original post a little.  What I'm looking for is the exact behavior I described.  When MAIN changes, so should the value of DEP.  I don't want to have to reassign any variables but MAIN.&lt;BR /&gt;&lt;BR /&gt;Does this make sense?&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies so far!&lt;BR /&gt;&lt;BR /&gt;Seth</description>
      <pubDate>Tue, 21 Jan 2003 01:16:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886115#M935826</guid>
      <dc:creator>Seth Parker</dc:creator>
      <dc:date>2003-01-21T01:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886116#M935827</link>
      <description>I'm not sure you can have the type of behavior you require.&lt;BR /&gt;&lt;BR /&gt;If you can, I don't know how to do it.</description>
      <pubDate>Tue, 21 Jan 2003 01:46:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886116#M935827</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-01-21T01:46:33Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886117#M935828</link>
      <description>Hi Seth&lt;BR /&gt;&lt;BR /&gt;Since you are treating DEP as a vraible too you would need to reset the same in case you need to change $MAIN , the other was would be to use a shell scirpt to attaint eh same which can have if with 2 conditons.In the shell it wont be possible as the youy are dealing with two variables , and to set that you would need 2 statements not one.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
      <pubDate>Tue, 21 Jan 2003 04:48:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886117#M935828</guid>
      <dc:creator>MANOJ SRIVASTAVA</dc:creator>
      <dc:date>2003-01-21T04:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886118#M935829</link>
      <description>This can be done using the eval command.&lt;BR /&gt;&lt;BR /&gt;Set DEP to a string that includes the name of the variable.&lt;BR /&gt;$ DEP="\$MAIN times"&lt;BR /&gt;This effectively defers evaluation of $MAIN.&lt;BR /&gt;$ echo $DEP&lt;BR /&gt;$MAIN times&lt;BR /&gt;MAIN=Sad&lt;BR /&gt;$ eval echo $DEP&lt;BR /&gt;Sad times&lt;BR /&gt;$ MAIN=Happy&lt;BR /&gt;$ eval echo $DEP&lt;BR /&gt;Happy times&lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Tue, 21 Jan 2003 10:36:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886118#M935829</guid>
      <dc:creator>Martin Robinson</dc:creator>
      <dc:date>2003-01-21T10:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886119#M935830</link>
      <description>10 points for Martin:&lt;BR /&gt;&lt;BR /&gt;Another example using awk:&lt;BR /&gt;&lt;BR /&gt;export BOX1=yellow                    &lt;BR /&gt;export BOX2=lightgreen                &lt;BR /&gt;export BOX3="#0080FF"&lt;BR /&gt;                       &lt;BR /&gt;awk '{  color=ENVIRON[$1]&lt;BR /&gt;print "" $1 ""} ' &amp;lt;&lt;END&gt;&lt;/END&gt;BOX1                                 &lt;BR /&gt;BOX2                                 &lt;BR /&gt;BOX3                                  &lt;BR /&gt;END&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jan 2003 11:42:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886119#M935830</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2003-01-21T11:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886120#M935831</link>
      <description>Nice, Martin!  I'm going to see how I can fit that in to what I'm doing.&lt;BR /&gt;&lt;BR /&gt;Thanks to you as well, Carlos.  Nice example, but not quite what I was looking for.&lt;BR /&gt;&lt;BR /&gt;And thanks to everyone else that took the time to reply.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Seth</description>
      <pubDate>Tue, 21 Jan 2003 16:01:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886120#M935831</guid>
      <dc:creator>Seth Parker</dc:creator>
      <dc:date>2003-01-21T16:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: How does one set a variable variable?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886121#M935832</link>
      <description>There is a sneaky way to get that effect without the eval syntax-&lt;BR /&gt;trap 'DEP=$MAIN" times"' DEBUG&lt;BR /&gt;&lt;BR /&gt;  That will execute the assignment after every shell command.  It is obviously high overhead.  And there is only one debug hook, so it is difficult to use independently for multiple associations.  You could use some kind of array of commands to aid with updates-&lt;BR /&gt;% trap 'for e in "${todo[@]}";do eval "$e";done;' DEBUG&lt;BR /&gt;% MAIN=sad&lt;BR /&gt;% echo MAIN=$MAIN DEP=$DEP                             &lt;BR /&gt;MAIN=sad DEP=&lt;BR /&gt;% todo[0]='DEP="$MAIN times"'&lt;BR /&gt;% echo MAIN=$MAIN DEP=$DEP   &lt;BR /&gt;MAIN=sad DEP=sad times&lt;BR /&gt;% MAIN=happy&lt;BR /&gt;% echo MAIN=$MAIN DEP=$DEP&lt;BR /&gt;MAIN=happy DEP=happy times&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Jan 2003 19:08:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-does-one-set-a-variable-variable/m-p/2886121#M935832</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2003-01-22T19:08:07Z</dc:date>
    </item>
  </channel>
</rss>

