<?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 script issue regarding variables in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112059#M149017</link>
    <description>Hello,&lt;BR /&gt;I'm writing a script and I have a problem with variables assignements. Here is what I want to do :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;LISTE_USER1="john gÃ©rard raoul"&lt;BR /&gt;LISTE_USER2="vincent gaston"&lt;BR /&gt;for USER in ${LISTE_$1}&lt;BR /&gt;do&lt;BR /&gt; .....&lt;BR /&gt;&lt;BR /&gt;And the script is meant to be called with a variable : for example&lt;BR /&gt;# script.sh USER1&lt;BR /&gt;&lt;BR /&gt;The problem is that ${LISTE_$1} doesn't work.&lt;BR /&gt;I get a "bad substitution" error message.&lt;BR /&gt;&lt;BR /&gt;Do you have a solution for this ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;T</description>
    <pubDate>Thu, 06 Nov 2003 06:45:33 GMT</pubDate>
    <dc:creator>System and Database</dc:creator>
    <dc:date>2003-11-06T06:45:33Z</dc:date>
    <item>
      <title>script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112059#M149017</link>
      <description>Hello,&lt;BR /&gt;I'm writing a script and I have a problem with variables assignements. Here is what I want to do :&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;LISTE_USER1="john gÃ©rard raoul"&lt;BR /&gt;LISTE_USER2="vincent gaston"&lt;BR /&gt;for USER in ${LISTE_$1}&lt;BR /&gt;do&lt;BR /&gt; .....&lt;BR /&gt;&lt;BR /&gt;And the script is meant to be called with a variable : for example&lt;BR /&gt;# script.sh USER1&lt;BR /&gt;&lt;BR /&gt;The problem is that ${LISTE_$1} doesn't work.&lt;BR /&gt;I get a "bad substitution" error message.&lt;BR /&gt;&lt;BR /&gt;Do you have a solution for this ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;T</description>
      <pubDate>Thu, 06 Nov 2003 06:45:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112059#M149017</guid>
      <dc:creator>System and Database</dc:creator>
      <dc:date>2003-11-06T06:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112060#M149018</link>
      <description>try&lt;BR /&gt; &lt;BR /&gt;for USER in LISTE_$1; do &lt;BR /&gt;echo \$$USER  &lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;do something useful instead of echo in the loop body with the variable</description>
      <pubDate>Thu, 06 Nov 2003 07:00:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112060#M149018</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-11-06T07:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112061#M149019</link>
      <description>forgot,&lt;BR /&gt;to have the loop variable evaluated in a command you might prepend the "eval" command in your loop body where you reference the variable USER.</description>
      <pubDate>Thu, 06 Nov 2003 07:08:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112061#M149019</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-11-06T07:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112062#M149020</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;as Ralph said "eval" is the key&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;LISTE_USER1="john gG8rard raoul"&lt;BR /&gt;LISTE_USER2="vincent gaston"&lt;BR /&gt;for USER in  `eval  echo \\$LISTE_\$1`&lt;BR /&gt;do&lt;BR /&gt;echo $USER&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Thu, 06 Nov 2003 07:38:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112062#M149020</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2003-11-06T07:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112063#M149021</link>
      <description>Personally I'd use arrays such as&lt;BR /&gt; &lt;BR /&gt;LISTE_USER[1]="john grard raoul"&lt;BR /&gt;LISTE_USER[2]="vincent gaston"&lt;BR /&gt;for USER in ${LISTE_USER[$1]}&lt;BR /&gt;do&lt;BR /&gt;echo $USER&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;Obviously this then gets called with arguments of 1, 2 etc</description>
      <pubDate>Thu, 06 Nov 2003 07:40:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112063#M149021</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-06T07:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: script issue regarding variables</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112064#M149022</link>
      <description>Thank you all for your answers ! I didn't know the "eval" command.&lt;BR /&gt;Tom</description>
      <pubDate>Thu, 06 Nov 2003 07:59:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-issue-regarding-variables/m-p/3112064#M149022</guid>
      <dc:creator>System and Database</dc:creator>
      <dc:date>2003-11-06T07:59:15Z</dc:date>
    </item>
  </channel>
</rss>

